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() { unsigned int i=65000; while(i++!=0); printf("%d",i); }

1 Answers  


prog. to produce 1 2 3 4 5 6 7 8 9 10

4 Answers   TCS,


main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

29 Answers   IBM, TCS, UGC NET, Wipro,


void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }

1 Answers  


Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.

5 Answers   Amazon, Microsoft,






void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }

1 Answers  


Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])

1 Answers  


write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }

1 Answers  


What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  


#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??

1 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


Categories