write a program to swap two numbers without using temporary
variable?

Answer Posted / guest

[code]

main()
{
int a=10;
int b=20;
printf("a = %d\nb = %d\n",a,b);
a =a+b; b=a-b; a=a-b; // This is first way.

a =a*b; b=a/b; a=a/b;
printf("a = %d\nb = %d\n",a,b);
}
[/code]

[code]
main()
{
int a=10;
int b=20;
printf("a = %d\nb = %d\n",a,b);
a =a*b; b=a/b; a=a/b; //This is second way
printf("a = %d\nb = %d\n",a,b);
}
[/code]




Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a macro, and explain how do you use it?

625


What is the best way to comment out a section of code that contains comments?

779


What is f'n in math?

619


What is return in c programming?

511


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

2184






write a program to rearrange the array such way that all even elements should come first and next come odd

1760


Is main is user defined function?

595


What are the types of pointers?

598


What is the difference between constant pointer and constant variable?

746


the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function

758


How does #define work?

644


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

623


Where does the name "C" come from, anyway?

643


What does p mean in physics?

581


explain what is fifo?

632