write a program to swap Two numbers without using temp variable.
Answer Posted / harisharumalla
#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 ? | 604 Yes | 119 No |
Post New Answer View All Answers
How do you list files in a directory?
What are run-time errors?
int i=10; printf("%d %d %d", i, i=20, i);
What is the difference between arrays and pointers?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
What is the difference between NULL and NUL?
Do you know what are the properties of union in c?
What is the significance of scope resolution operator?
Explain what is a program flowchart and explain how does it help in writing a program?
Is a pointer a kind of array?
Explain the difference between strcpy() and memcpy() function?
Explain main function in c?
Can the curly brackets { } be used to enclose a single line of code?
Array is an lvalue or not?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd