WRITE A PROGRAM TO INTERCHANGE THE CONTENTS OF THE TWO VARIABLES WITHOUT USING ANY THIRD VARIABLE
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two numbers a and b:");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("New values of a and b are %d, %d",a,b);
getch();
}
Output:
Enter two numbers a and b: 5
6
New values of a and b are 6,5
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two numbers a and b:");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("New values of a and b are %d, %d",a,b);
getch();
}
Output:
Enter two numbers a and b: 5
6
New values of a and b are 6,5
No comments:
Post a Comment