Program to input two number and print their values after interchange(Swap) without using third value.
/* Program to swap two number in C */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter first number=");
scanf("%d",&a);
printf("Enter second number=");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("\nFirst number=%d",a);
printf("\nSecond number=%d",b);
getch();
}
OUTPUT
Note:If any problems in this program please comment and never forget to Share.
Follow for recently updates.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter first number=");
scanf("%d",&a);
printf("Enter second number=");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("\nFirst number=%d",a);
printf("\nSecond number=%d",b);
getch();
}
OUTPUT
Note:If any problems in this program please comment and never forget to Share.
Follow for recently updates.
Comments
Post a Comment