write a origram swaoing valu without 3rd variable

Answers were Sorted based on User's Feedback



write a origram swaoing valu without 3rd variable..

Answer / jeevanvns

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the valu");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("%d\t %d\t",a,b);
getch();
}

Is This Answer Correct ?    8 Yes 0 No

write a origram swaoing valu without 3rd variable..

Answer / tejesh

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value");
scanf("%d%d",&a,&b);
a=a^b; //xor operator -- ^
b=a^b;
a=a^b;
printf("%d\t %d\t",a,b);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

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

2 Answers  


void pascal f(int i,int j,int k) { printf(ā€œ%d %d %dā€,i, j, k); } void cdecl f(int i,int j,int k) { printf(ā€œ%d %d %dā€,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

1 Answers  


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

4 Answers   TCS,


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

2 Answers   HCL,


Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

1 Answers  






#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }

1 Answers  


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

2 Answers  


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  


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

2 Answers  


Write a C program to add two numbers before the main function is called.

11 Answers   Infotech, TC,


Develop a routine to reflect an object about an arbitrarily selected plane

0 Answers  


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); }

1 Answers  


Categories