How many ways are there to swap two numbers without using
temporary variable? Give the each logic.
Answer Posted / gana samantula
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(" Enter the first No.:");
scanf("%d",&a);
printf(" Enter the second No.:");
scanf("%d",&b);
b=a+b-(a=b);
printf(" the swap of a and b numbers :%d %d",a,b);
getch();
}
| Is This Answer Correct ? | 14 Yes | 0 No |
Post New Answer View All Answers
What is the best way to store flag values in a program?
What is the most efficient way to count the number of bits which are set in an integer?
What are register variables? What are the advantage of using register variables?
what is different between auto and local static? why should we use local static?
How macro execution is faster than function ?
How do you search data in a data file using random access method?
Is it possible to pass an entire structure to functions?
how do you programme Carrier Sense Multiple Access
When should you use a type cast?
how to write a c program to print list of fruits in alpabetical order?
What are variables and it what way is it different from constants?
What is putchar() function?
What is the meaning of typedef struct in c?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
What do you mean by a local block?