write a program to swap Two numbers without using temp variable.
Answer Posted / gaurav sharma
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a,b;
printf("enter the value of a : ");
scanf("%d",&a);
printf("enter the value of b : ");
scanf("%d",&b);
printf("Before swapping a is %d and b is %d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\nAfter swapping of a and b:\na=%d\nb=%d",a,b);
getch();
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Tell us something about keyword 'auto'.
Why c is a mother language?
How can I change the size of the dynamically allocated array?
What is infinite loop?
What is cohesion in c?
What is bss in c?
What is the use of in c?
What is the difference between ++a and a++?
What is a pointer on a pointer in c programming language?
Explain how can I write functions that take a variable number of arguments?
What is the difference between array_name and &array_name?
Why c is called a mid level programming language?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What is keyword with example?
Compare array data type to pointer data type