Write a C-program to swap two number:
Swap Two Number:
Tips:
1.Take three variables.
2.Take two inputs from user.
3.Assign variables one by one each other.
Code:
main()
{
int a,b,s;
printf("Enter two number two swap:\n");
scanf("%d%d",&a,&b);
printf("\nyou decide:\na=%d and b=%d",a,b);
getch(0);
s=a;
a=b;
b=s;
printf("\nThe swap number is: a=%d and b=%d",a,b);
getch();
}
{
int a,b,s;
printf("Enter two number two swap:\n");
scanf("%d%d",&a,&b);
printf("\nyou decide:\na=%d and b=%d",a,b);
getch(0);
s=a;
a=b;
b=s;
printf("\nThe swap number is: a=%d and b=%d",a,b);
getch();
}
Output:
Please comment!
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)