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

Explain low-order bytes.

0 Answers  


Explain the differences between public, protected, private and internal.

2 Answers  


Why c is called a middle level language?

0 Answers  


What is identifier in c?

0 Answers  


Study the Following Points: a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static 1. Which of the Following Statements are true w.r.t Bit- Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture,


main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); } output?

7 Answers   Ramco,


What is the difference between the local variable and global variable in c?

0 Answers  


Why c language is called c?

0 Answers  


What is the difference between malloc() and calloc() function in c language?

0 Answers  


c program to print a name without using semicolon

9 Answers   TCS, Wipro,


How can I avoid the abort, retry, fail messages?

0 Answers  


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

0 Answers   Google,


Categories