Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


main()

{

void swap();

int x=10,y=8;

swap(&x,&y);

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

Explanation:

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 ?    4 Yes 0 No

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

Answer / shruthi

x=8,y=10

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Code Interview Questions

struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


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

3 Answers  


write the function. if all the character in string B appear in string A, return true, otherwise return false.

11 Answers   Google,


main() { void swap(); int x=10,y=8; swap(&x,&y); printf("x=%d y=%d",x,y); } void swap(int *a, int *b) { *a ^= *b, *b ^= *a, *a ^= *b; }

2 Answers  


write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


All the combinations of prime numbers whose sum gives 32

1 Answers   HHH,


#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }

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,


&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

2 Answers  


Categories