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

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...