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 can I find the modification date of a file?

689


Explain how do you override a defined macro?

573


How can I dynamically allocate arrays?

579


write a program to print data of 5 five students with structures?

1596


What is typedef?

655






What is variable initialization and why is it important?

607


Is c easy to learn?

550


What does c value mean?

612


Hi can anyone tell what is a start up code?

1602


Is python a c language?

542


How would you rename a function in C?

606


What are the key features in c programming language?

599


What is nested structure with example?

611


Are there namespaces in c?

556


Why is not a pointer null after calling free?

583