Program to swap two numbers in C.

 

01 #include <stdio.h>
02
03 int main()
04 {
05
06 int x, y, temp;
07
08 printf("Enter the value of x and y ");
09 scanf("%d%d", &x, &y);
10
11 printf("Before Swapping x = %d y = %d ",x,y);
12
13 temp = x;
14 x = y;
15 y = temp;
16
17 printf("After Swapping x = %d y = %d ",x,y);
18
19 return 0;
20 }
 
 OUTPUT :

Enter the value of x and y
23
54
Before Swapping
x = 23
y = 54

After Swapping
x = 54
y = 23

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.