CODE BOX
Pages
Home
Data Types
Algorithms
Easy Find
Linux Commands
Friday, 4 September 2015
WAP to swap the values of two integer variables, without using extra variable
#include <stdio.h>
int main ()
{
int a,b;
printf("Enter 1st number: ");
scanf("%d",&a);
printf("Enter 2nd number: ");
scanf("%d",&b);
printf("a = %d b = %d\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swaping a = %d b = %d\n",a,b);
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment