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 is the correct declaration of main?
Explain null pointer.
What is pointer to pointer in c with example?
What are the usage of pointer in c?
Explain the difference between the local variable and global variable in c?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
Can a local variable be volatile in c?
What is #define?
What is the size of empty structure in c?
How can you read a directory in a C program?
What is array in C
What is the time and space complexities of merge sort and when is it preferred over quick sort?
What is the need of structure in c?
How do you use a 'Local Block'?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none