Monday, 9 July 2018

C Program Swap Two Numbers

                               Swap Two Numbers:-

C program Swapping Of Two Number in this program swap two Numbers first of all use standard library then star main function declare three variable x,y and temp then run time user enter the value of  x and y then swap each other
CODE:-
#include <stdio.h>//standard library
int main()//start main function
{
int x;//declare integer variable x
int y;//declare integer variable y
int temp;//declare temp variable
printf("Enter the value of x and y\n");
scanf("%d%d", &x, &y);
printf("Before Swapping\nx = %d\ny = %d\n",x,y);
temp = x;//Basic formula swapping the number
x = y;
y = temp;
printf("After Swapping\nx = %d\ny = %d\n",x,y);
return 0;
}

No comments:

Post a Comment

Thanks for comment