write a program to swap Two numbers without using temp variable.
Answer Posted / tamal datta
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n Enter a = ");
scanf("%d",&a);
printf("\n Enter b = ");
scanf ("%d",&b);
printf ("\nBefore swapping a = %d",a);
printf ("\nBefore swapping b = %d",b);
//swaping of 2 numbers without using temp variable
a=a+b;
b=a-b;
a=a-b;
printf("\nAfter swapping a = %d",a);
printf ("\nAfter swapping b= %d",b);
getch();
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What are multibyte characters?
Why is it that not all header files are declared in every C program?
What is sizeof c?
Is malloc memset faster than calloc?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
Is c easier than java?
cavium networks written test pattern ..
What is difference between array and pointer in c?
What are global variables?
Explain how do you print an address?
Explain pointer. What are function pointers in C?
What are the advantages of external class?
why do some people write if(0 == x) instead of if(x == 0)?
Explain c preprocessor?
What are valid signatures for the Main function?