Wednesday, 6 June 2018

Program to swapping of two variable using pointer in c language

/* swapping of two variables */
# include <stdio.h>
void swap (int* , int*) ;                            /* variable declaration */
void main ()
{
int a,b ;
clrscr () ;
printf ("\n Enter value of a :") ;
scanf ("%d", & a) ;
printf ("\n Enter value of b:") ;
scanf ("%d", & b) ;
swap (&a , &b) ;                               /* variable assignment */
printf ("\n a =%d b=%d ", a,b) ;
getch () ;
}
void swap (int*a , int*b)
{
int temp ;
temp = *a ;
*a = *b ;
*b = temp ;
}


No comments:

Post a Comment

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...