write a program to swap Two numbers without using temp variable.
Answer Posted / amit chauhan
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n Enter the 2 numbers");
scanf("%d%d",&a,&b);
//swaping of 2 numbers without using temp variable
a=a+b;
b=a-b;
a=a-b;
/* or
a=a*b;
b=a/b;
a=a/b;
*/
printf("\n A = %d \n B = %d\n");
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are preprocessor directives in c?
Explain how can I read and write comma-delimited text?
Is it acceptable to declare/define a variable in a c header?
What is the use of structure padding in c?
Why c is called object oriented language?
What is register variable in c language?
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9
What is bubble sort in c?
What is structure in c language?
What is the use of bitwise operator?
What is optimization in c?
how to capitalise first letter of each word in a given string?
Is exit(status) truly equivalent to returning the same status from main?
Can the “if” function be used in comparing strings?
What is the difference between if else and switchstatement