Follow Our FB Page << >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...



void swap();

int x=10,y=8;


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


void swap(int *a, int *b)


*a ^= *b, *b ^= *a, *a ^= *b;


Answers were Sorted based on User's Feedback

main() { void swap(); int x=10,y=8; swap(&x,&y); ..

Answer / susie

Answer :

x=10 y=8


Using ^ like this is a way to swap two variables without
using a temporary variable and that too in a single statement.

Inside main(), void swap(); means that swap is a function
that may take any number of arguments (not no arguments) and
returns nothing. So this doesn’t issue a compiler error by
the call swap(&x,&y); that has two arguments.

This convention is historically due to pre-ANSI style
(referred to as Kernighan and Ritchie style) style of
function declaration. In that style, the swap function will
be defined as follows,

void swap()

int *a, int *b


*a ^= *b, *b ^= *a, *a ^= *b;


where the arguments follow the (). So naturally the
declaration for swap will look like, void swap() which means
the swap can take any number of arguments.

Is This Answer Correct ?    2 Yes 0 No

main() { void swap(); int x=10,y=8; swap(&x,&y); ..

Answer / shruthi


Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

plz send me all data structure related programs

2 Answers  

Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

3 Answers   Disney, Google, ZS Associates,

how can i search an element in an array

2 Answers   CTS, Microsoft, ViPrak,

What are segment and offset addresses?

2 Answers   Infosys,

main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }

1 Answers  

What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

0 Answers  

abcdedcba abc cba ab ba a a

2 Answers  

main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above

2 Answers   HCL,

write a c-program to display the time using FOR loop

3 Answers   HCL,

main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }

2 Answers   Wipro,

code of a program in c language that ask a number and print its decremented and incremented number.. sample output: input number : 3 321123

1 Answers   HCL,

How do you write a program which produces its own source code as its output?

7 Answers