write a program to swap Two numbers without using temp variable.

Answer Posted / amit chauhan

#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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to use switch statement.

652


c language interview questions & answer

1452


What does c mean in basketball?

553


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2328


What is graph in c?

577






Why is c called c not d or e?

600


What is the right type to use for boolean values in c?

576


Why do we write return 0 in c?

542


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

695


What does main () mean in c?

605


How do you search data in a data file using random access method?

823


What is p in text message?

529


What are different types of variables in c?

563


What was noalias and what ever happened to it?

586


What is the difference between far and near in c?

589