write a program to swap Two numbers without using temp variable.
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
write a program that explain #define and # undef directive
In C language, a variable name cannot contain?
explain how do you use macro?
What are file streams?
Can we access array using pointer in c language?
Why can't I perform arithmetic on a void* pointer?
How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include<stdio.h>...
how to find string length wihtout using c function?
what is difference between ++(*p) and (*p)++
17 Answers Accenture, HCL, IBM,
What's the right way to use errno?
What are the types of operators in c?
What is a constant and types of constants in c?