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
What is malloc() function?
Explain how can you tell whether two strings are the same?
What is the use of sizeof?
How can I determine whether a machines byte order is big-endian or little-endian?
Can stdout be forced to print somewhere other than the screen?
What are types of preprocessor in c?
Where static variables are stored in memory in c?
Which is best book for data structures in c?
What is structure in c definition?
What 'lex' does?
what do u mean by Direct access files? then can u explain about Direct Access Files?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
I have a varargs function which accepts a float parameter?
Write a c program to demonstrate character and string constants?
What is a buffer in c?