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 maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...