Write a program to interchange two variables without using
the third variable?

Answers were Sorted based on User's Feedback



Write a program to interchange two variables without using the third variable?..

Answer / ramesh mca gprec knl

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter two no");
scanf("%d%d",&a,&b);
c=a*b;
b=a/b;
a=b/a;
printf("After chanching no is =\n");
printf("a=%d b=%d",a,b);
getch();
}

Is This Answer Correct ?    1 Yes 4 No

Write a program to interchange two variables without using the third variable?..

Answer / kumar

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter two no");
scanf("%d%d",&a,&b);
a=b-0;
b=a-0;
printf("a=%d b=%d",a,b);
getch();
}

Is This Answer Correct ?    0 Yes 4 No

Write a program to interchange two variables without using the third variable?..

Answer / neelam

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two no.s 4 swap");
scanf("%d%d",&a,&b);
a=a+b;;
b=a-b;
a=a-b;
printf("After swapping no.s are =\n");
printf("a=%d b=%d",a,b);
getch();
}

Is This Answer Correct ?    0 Yes 4 No

Write a program to interchange two variables without using the third variable?..

Answer / satish

#include<stdio.h>
void main()
{
int x,y;
printf("enter x and y: ");
scanf("%d%d",&x,&y);
x^=y^=x^=y;
printf("elements after swapping: %d,%d\n",x,y);
}

Is This Answer Correct ?    20 Yes 26 No

Write a program to interchange two variables without using the third variable?..

Answer / deepa.n

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two no");
scanf("%d%d",&a,&b);
a=a*b;
b=a/b;
a=b/a;
printf("After chanching no is =\n");
printf("a=%d b=%d",a,b);
getch();
}

Is This Answer Correct ?    8 Yes 14 No

Write a program to interchange two variables without using the third variable?..

Answer / deepa.n

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter two no");
scanf("%d%d",&a,&b);
c=a*b;
b=a/b;
a=b/a;
printf("After chanching no is =\n");
printf("a=%d b=%d",a,b);
getch();
}

Is This Answer Correct ?    15 Yes 26 No

Write a program to interchange two variables without using the third variable?..

Answer / mahendra giri

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter two no");
scanf("%d%d",&a,&b);
c=a+b;
b=a-b;
a=a-b;
printf("After chanching no is =\n");
printf("a=%d b=%d",a,b);
getch();
}

Is This Answer Correct ?    23 Yes 44 No

Post New Answer

More C Interview Questions

Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort

3 Answers  


What is difference between stdio h and conio h?

0 Answers  


What are the scope of static variables?

0 Answers  


to get a line of text and count the number of vowels in it

3 Answers   Satyam,


how to add two numbers without using arithmetic operators?

4 Answers  






main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

11 Answers   CISOC, CitiGroup, College School Exams Tests,


When should you use a type cast?

0 Answers  


Combinations of fibanocci prime series

0 Answers  


f(x,y,z) { y = y+1; z = z+x; } main() { int a,b; a = 2 b = 2; f(a+b,a,a); print a; } what is the value of 'a' printed

5 Answers  


int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?

4 Answers   TCS,


implement NAND gate logic in C code without using any bitwise operatior.

4 Answers   Alcatel,


Does free set pointer to null?

0 Answers  


Categories