answersLogoWhite

0

int varA, varB;

int tmp;

// common way to swap 2 variables in the same type;

tmp = varA; // store the original value of varA

varA = varB; // assign A with B

varB = tmp; // B now has the original value of varA

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

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;


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

a=a^b; b=a^b; a=a^b;


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

Use list assignment i.e. for two variables $a, $b: ($a,$b) = ($b,$a)


Multiple by 7 without using multiplication?

You can't. Multiple is how you do multiplication


When possible you should advoid using what variables in a program?

Global Variables Or: variables with names longer than 128 characters.


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<stdio.h> 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..........


When possible you should avoid using variables in a program.?

global


C program for matrix multiplication using dynamic memory alllocation?

Poor boy


What is the rule for using variables and number with an exponent of 1?

An exponent of 1 can be ignored. In the same way that multiplication by 1 can be ignored.


What are all the symbols for multiplication?

There 3 to 4 symbols of multiplication depending on the condition.If you are using computer for calculation the only symbol of multiplication is *.If you are using calculator the symbol for multiplication is x.If you are solving equation in paper the symbol for multiplication b/w variables are mostly represent by a dot(.) or the place is left empty. A.B or AxB the answer will be same is scalar calculation but will be different on vector calculation. If use scalar calculation 'AB' will also represent multiplication b/w two variables. But it is only applicable on variables.If we use scalar number in equation like 3(4-3)*3=9; here '3(' is representing the multiplication b/w the number and the bracket. If there is any number before a bracket without any symbol then this will show that the number is multiplying by the bracket values.


If polynomial is not any number then how will you define a polynomial?

An expression made with constants, variables and exponents, which are combined using addition, subtraction and multiplication, ... but not division.


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;