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

Design a program using an array that searches a number if it is found on the list of the given input numbers and locate its exact location in the list.

4 Answers  


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

0 Answers  


What is the difference between int and float?

3 Answers  


How would you rename a function in C?

0 Answers   Tech Mahindra,


what is the difference between #include<> and #include”…”?

5 Answers  


How can you find out how much memory is available?

0 Answers  


what are threads ? why they are called light weight processes ? what is the relation between process and threads ?

1 Answers  


What is the difference between Printf(..) and sprint(...) ?

0 Answers   InterGraph,


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

0 Answers   Mind Tree,


difference between ordinary variable and pointer in C?

2 Answers  


What is a static variable in c?

0 Answers  


wap in c to accept a number display the total count of digit

4 Answers  


Categories