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

How do you list files in a directory?

771


What are run-time errors?

785


int i=10; printf("%d %d %d", i, i=20, i);

1270


What is the difference between arrays and pointers?

822


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

872






What is the difference between NULL and NUL?

974


Do you know what are the properties of union in c?

763


What is the significance of scope resolution operator?

1094


Explain what is a program flowchart and explain how does it help in writing a program?

839


Is a pointer a kind of array?

794


Explain the difference between strcpy() and memcpy() function?

760


Explain main function in c?

821


Can the curly brackets { } be used to enclose a single line of code?

917


Array is an lvalue or not?

826


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

821