C PROGRAMMING

write a c program to swap two variables usign temp variable

 

#include <stdio.h>
main()
{
int x, y, temp;
printf("Enter first numbern");
scanf("%d",&x);
printf("Enter second numbern");
scanf("%d",&y);
printf("Before Swapping: x = %d y = %dn", x, y);
temp = x;
x = y;
y = temp;
printf("After Swapping: x = %d y = %d", x, y);
getch();
}

Related Articles

Leave a Reply

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

Back to top button