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() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30

0 Answers  


Is the following code legal? struct a { int x; struct a *b; }

2 Answers  


char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }

1 Answers  


How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)

4 Answers   HCL,






Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

13 Answers   Intel, Microsoft, TCS,


main() { show(); } void show() { printf("I'm the greatest"); }

2 Answers  


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

2 Answers  


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


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  


main() { printf("%d", out); } int out=100;

3 Answers  


Categories