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


Please Help Members By Posting Answers For Below Questions

What is malloc() function?

638


Explain how can you tell whether two strings are the same?

585


What is the use of sizeof?

557


How can I determine whether a machines byte order is big-endian or little-endian?

622


Can stdout be forced to print somewhere other than the screen?

627






What are types of preprocessor in c?

621


Where static variables are stored in memory in c?

524


Which is best book for data structures in c?

600


What is structure in c definition?

576


What 'lex' does?

720


what do u mean by Direct access files? then can u explain about Direct Access Files?

1643


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

670


I have a varargs function which accepts a float parameter?

580


Write a c program to demonstrate character and string constants?

1685


What is a buffer in c?

576