C Program to swap two numbers without using temp variable - c programs
//C Program to swap two numbers without using temp variable
#include <stdio.h>
#include <conio.h>
main()
{
int a,b;
clrscr();
printf("enter two numbers");
scanf("%d%d",&a, &b);
printf("the value of a is %d" ,a);
printf("the value of b is %d" ,b);
a=a+b;
b=a-b;
a=a-b;
printf("the value of a after swapping is %d" ,a);
printf("the value of b after swapping is %d" ,b);
getch();
}
#include <conio.h>
main()
{
int a,b;
clrscr();
printf("enter two numbers");
scanf("%d%d",&a, &b);
printf("the value of a is %d" ,a);
printf("the value of b is %d" ,b);
a=a+b;
b=a-b;
a=a-b;
printf("the value of a after swapping is %d" ,a);
printf("the value of b after swapping is %d" ,b);
getch();
}
No comments:
Post a Comment