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

Answers were Sorted based on User's Feedback



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

Answer / jaspreet singh

no sree although it swap the xalues but when we give the
input as a=32767 n b=1 it will give the wrong answer

Is This Answer Correct ?    17 Yes 22 No

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

Answer / tamerat

q

Is This Answer Correct ?    8 Yes 13 No

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

Answer / nagarjun

main()
{
int a=4,b=5;
/*b=(a+b)-(a=b);*/
a^=b^=a^=b;
printf(" \n %d %d \n",a,b);
}

Is This Answer Correct ?    21 Yes 28 No

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

Answer / naresh

main()
{
int a,b,c;
printf("enter a,b value");
scanf("%d%%d",&a,&b);
c=a^=b^=a^=b;
printf("%d",c);
}

Is This Answer Correct ?    67 Yes 150 No

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

Answer / yash paranjape

int main()
{
int a,b;
printf("enter the two numbers");
scanf("%d%d",&a,&b);
a^=b^=c^=a;//swap a and b
printf("%d%d",a,b);//numbers r swapped
}

Is This Answer Correct ?    82 Yes 189 No

Post New Answer

More C Interview Questions

increment operateor (++)and decrament(--) #include<stdio.h> #inclide<conio.h> main() { int x=15; while(x!=0) scanf("%d",&x); {

2 Answers   HCL, Syntel, TCS,


#define DCHAR char* typedef char* TCHAR; if using these following variables will be declared like DCHAR ch1, ch2; TCHAR ch3, ch4; then what will be types of ch1, ch2, ch3 and ch4?

6 Answers   NDS,


Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: “jack and jill went up a hill” Return Value: “kcaj dna llij tnew pu a llih”

5 Answers   Mind Tree,


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } what is the output?

9 Answers   Ramco,


What is the difference between char array and char pointer?

0 Answers  






What is spark map function?

0 Answers  


write a recursive program in'c'to find whether a given five digit number is a palindrome or not

2 Answers  


What is difference between array and pointer in c?

0 Answers  


How are structure passing and returning implemented?

0 Answers  


What is the condition that is applied with ?: Operator?

0 Answers  


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

0 Answers  


When should a far pointer be used?

0 Answers   Aspire, Infogain,


Categories