Write a C Program to Swapping of Two Numbers
Program:
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf("Enter value of a: ");
scanf("%d",&a);
printf("Enter value of b: ");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("After swapping a=: %d b=: %d",a,b);
getch();
}
..........................................................................................................
Output
Enter value of a: 43
Enter value of b: 33
After swapping a=: 33 b=: 43
--------------------------------
Process exited after 13.22 seconds with return value 0
Press any key to continue . . .
Program:
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf("Enter value of a: ");
scanf("%d",&a);
printf("Enter value of b: ");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("After swapping a=: %d b=: %d",a,b);
getch();
}
..........................................................................................................
Output
Enter value of a: 43
Enter value of b: 33
After swapping a=: 33 b=: 43
--------------------------------
Process exited after 13.22 seconds with return value 0
Press any key to continue . . .
0 Comments:
Post a Comment