HOW TO SWAP TWO NOS IN ONE STEP?

Answers were Sorted based on User's Feedback



HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / shiva kumar

void main()
{
int a,b;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
b=a+b-(a=b);
printf("%d %d ",a,b);
}

Is This Answer Correct ?    28 Yes 7 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / rajkumar

(a=a-(b=(a=a+b)-b));

Is This Answer Correct ?    9 Yes 3 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / ashik

#define swap(a,b) a^=b^=a^=b;

Is This Answer Correct ?    6 Yes 4 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / sasikumar

main()
{
int a,b,c;
printf("enter two no's :");
scanf("%d%d",&a,&b);
c=a^=b^=a^=b;
printf("%d",c);
}

Is This Answer Correct ?    6 Yes 6 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / vijay

#include<stdio.h>
main()
{
int a=5,b=9;
printf("%d %d \n",a,b);
a^=b^=a^=b;
printf("%d %d \n",a,b);
}

Is This Answer Correct ?    4 Yes 4 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / sumit

b=abs((a=b)-(a+b));

Is This Answer Correct ?    1 Yes 1 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / eswaran

Sasi kumar answer is very wrong answer .....

Is This Answer Correct ?    0 Yes 0 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / venkatesh sabinkar

#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=2,t;
clrscr();
printf("a=%d,b=%d",a,b,b=t,a=b,t=a);
getch();
}

Is This Answer Correct ?    3 Yes 4 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / z

Trick question: the phrase "one step" is undefined.
Example: how many steps are there in the following statement?
a = ++b;

Is This Answer Correct ?    0 Yes 1 No

HOW TO SWAP TWO NOS IN ONE STEP?..

Answer / amaresh chandra das

amaresh@Hare-Krishna:~$ cat swp.c
#include<stdio.h>
int
main(){
int a=5,b=6; // Compile using gcc -Wall
#ifdef DEBUG // to avoid compiler warnings
a ^=b^=a^=b;
#endif
printf("value of a is %d and b is %d\n",a,b);
return 0;
}

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More C Interview Questions

Explain that why C is procedural?

0 Answers   Maveric, Verifone,


What is oops c?

0 Answers  


Describe advantages and disadvantages of the various stock sorting algorithms

1 Answers   Microsoft,


Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press 'g' it shows the answer 7.. any can help me

7 Answers  


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

0 Answers  






Explain what is wrong with this program statement?

0 Answers  


Why should I use standard library functions instead of writing my own?

0 Answers  


struct node {struct node*temp,*new} prinf("%d",sizeof(struct node));

2 Answers  


What is NULL pointer?

0 Answers   Infosys,


void main() {int a[5],i,b=16; for(i=0;i<5;i++) a[i]=2*i; f(a,5,b); for(i=0;i<5;i++) printf("\n %d",a[i]); printf("\n %d",b); } f(int *x,int n,int y) { int i; for(i=0;i<n;i++) *(x+i)+=2; y=y+2; }wat r the errors in the prg.and improvise the prg to get o/p.?

2 Answers   TCS,


What is action and transformation in spark?

0 Answers  


What is the purpose of the preprocessor directive error?

0 Answers  


Categories