answersLogoWhite

0


Best Answer

The required c program is given below

/*Swapping(interchange) the two entered numbers*/

#include<stdio.h>

main()

{

/*Without using third variable*/

int a,b,t;

printf("Enter a:");

scanf("%d",&a);

printf("Enter b:");

scanf("%d",&b);

a=a+b;

b=a-b;

a=a-b;

printf("\n After swapping without using third variable");

printf("\na=%d\nb=%d",a,b);

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

To swap two numbers without using a temporary variable, use the bitwise exclusive or function...

A^=B;

B^=A;

A^=B;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is program in c to swap entered two numbers without using third variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program for sorting for numbers without repited values?

Any number variable is extends the Number in java and it already implemented Comparable interface. So when you have a list of numbers, just use Arrays.sort().


How does one use french letters on Windows without downloading a program?

You can use Alt codes, which are codes that can be entered by holding down the Alt key as you enter numbers on the numpad.


Can you run java program without applying main method?

yes we can run java program without using main. we can run program by declaring the variable static..


What is the output displayed by the following program when the data entered are 5 and 7?

Impossible to say without seeing the program's source.


Can you write addition of 2 no program without using third variable?

Yes. int a, b; a= 2; b= 3; a= a+b;


How can you accept sum and print numbers without creating variables?

It is very easy. The program begins here..... /*Program to sum and print numbers without creating variables*/ #include&lt;stdio.h&gt; main() { clrscr(); printf("%d+%d=%d",5,2,5+2); getch(); } /*Program ends here*/ Now just by changing the numbers in the "printf" statement we can add, subtract, multiply and divide the numbers without using variables. Hence the problem is solved..........


what type of variable is visible to every module and the entire program?

If you are talking about a class in Java, a variable encapsulated by a class is called an instance variable b/c everytime you create an object with that class, each object has its own set of the variables declared.


How do we write c program without using swap to interchange values by accessing another variable?

int a,b; a=a+b; b=a-b; a=a-b; that's it simple


What is the independent variable of a variable?

Just the number, for example: 7x the variable is 7. The variable is the number without the variable(x,y,z, etc.)


How do you write a program in C plus plus plus plus How do you write a program in C to swap two variables without using the third oneo swap two variables without using the third one?

To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;


What is the Algorithm for exchanging values of two variables?

There are three primary algorithms to exchange the values of two variables. Exchange with Temporary Variable temp = a; a = b; b = temp; Exchange Without Temporary Variable Using Exclusive Or a = a ^ b; b = b ^ a; a = a ^ b; Exchange Without Temporary Variable Using Arithmetic a = a + b; b = b - a; a = a - b;


What is the word for a term without a variable?

If a term doesn't have a variable , then its probably a constant.