write a program to swap two numbers without using temporary
variable?
Answers were Sorted based on User's Feedback
Answer / it diploma student
let a and b be the variables
a=a+b
b=a-b
a=a-b
if we take a=5 and b = 7 then
a = 5+7 = 12
b = 12-7 = 5
a = 12-5 = 7
hence swaped...
Is This Answer Correct ? | 26 Yes | 3 No |
Answer / 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 |
Answer / sam
let a and b be variables
a^=b^=a^=b;
by performing this logic from right hand side we can swap
two variables
Is This Answer Correct ? | 6 Yes | 5 No |
Write the program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures.
How do I use void main?
What is the output for the below program? void main() { float me=1.1; double you=1.1; if(me==you) printf("love c"); else printf("know c"); }
show how link list can be used to repersent the following polynomial i) 5x+2
What is the auto keyword good for?
what is the format specifier for printing a pointer value?
What is the OOPs concept?
What is pointer in c?
Can anyone help me with this please? Need to print the below values.. Thanks 1 1 2 1 2 3 1 2 3 4
State the difference between x3 and x[3].
How variables are declared in c?
Write a program to find the given number is odd or even without using any loops(if,for,do,while)