int swap(int *a,int *b)

{

*a=*a+*b;*b=*a-*b;*a=*a-*b;

}

main()

{

int x=10,y=20;

swap(&x,&y);

printf("x= %d y = %d\n",x,y);

}



int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() ..

Answer / susie

Answer :

x = 20 y = 10

Explanation

This is one way of swapping two values. Simple checking will
help understand this.

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { int i=5; printf(ā€œ%dā€,i=++i ==6); }

1 Answers  


Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..

2 Answers  


How we will connect multiple client ? (without using fork,thread)

3 Answers   TelDNA,


could you please send the program code for multiplying sparse matrix in c????

0 Answers  


Implement a t9 mobile dictionary. (Give code with explanation )

1 Answers   Amazon, Peak6, Yahoo,






#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

1 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


how to delete an element in an array

2 Answers   IBM,


typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


What is "far" and "near" pointers in "c"...?

3 Answers  


main() { printf("\nab"); printf("\bsi"); printf("\rha"); }

3 Answers  


Categories