Swap two numbers

Program:

#include<stdio.h>
int main()
{
 int x,y,temp;
 printf("Enter two numbers: \n");
 scanf("%d %d",&x,&y);
 printf("Before swapping x=%d and y=%d\n",x,y);
 temp=x;
 x=y;
 y=temp;
 printf("After swapping x=%d and y=%d\n",x,y);
 return 0;

}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...