answersLogoWhite

0


Best Answer

Suppose we ask the user to enter a range with an upper and lower limit. We would naturally expect the upper limit to be higher in value than the lower limit. If this is not the case, we can either reject the values and ask for new input or we can simply swap them.

if we have an array of unsorted values and we wish to sort them, we need to exchange values. In order to exchange any two values we must swap them.

User Avatar

Wiki User

βˆ™ 8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the importance of Swapping two variables?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the advantage of swapping two variables without using 3 variable?

Nothing. Never do that.


What is meant by swapping of variables?

It means that you swap the values of that variables EX: -==- before swapping :- Variable1 = 5; variable2 = 10; after swapping :- Variable1 = 10; variable2 = 5;


What are the importance of linear equation?

They are the simplest form of relationship between two variables. Non-linear equations are often converted - by transforming variables - to linear equations.


What is the meaning of 'swapping' in computer architecture?

Swapping means to swap the values of two addresses in main memory.


How do you write a c program to swap the values of two variables in unix?

#include<stdio.h> void main() { int a=2,b=4; printf("Program for swapping two numbers "); printf("Numbers before swapping"); printf("a=%d and b=%d",a,b); a=((a+b)-(b=a)); printf("Numbers after swapping"); printf("a=%d and b=%d",a,b); getch(); }


Importance of line graph?

The major importance of a line graph is that it allows a person to visually see the relationship between two major variables. A line graph contains a vertical axis and a horizontal axis.


What is the flowchart for swapping two variables?

include#includevoid main(){int x, y, temp;printf("Enter the value of x and y ");scanf("d", &x, &y);printf("Before Swapping x = %d\ny = %d\n",x,y);temp = x;x = y;y = temp;printf("After Swapping x = %d\ny = %d\n",x,y);getch();return 0;}Do you happen to know what a flow-chart is?


Swapping of two variables withou using temp variable?

example: x = x-y; y = y-x; x = y-x; <><><> It is not possible to swap two variables without using a temp variable. The code in the answer above, while clever, does not swap the variables. It will exchange the variable values for certain values of x and y, e.g. when x and y are small integers. If x and y are other values, such as strings, pointers, Infinity, NaN (not a number), floating point, or near the limits of the representation (causing over/underflow) then the code will not "swap" the values. <---> Note: there is absolutely no point in swapping two variables without using temopral variable, it's just a typical homework question, already asked here countless times. Another variation: a ^= b; b ^= a; a ^= b;


Program designed to swap the values of two variables?

You'll need 3 variables for this, here's a pseudo code for swapping values of 2 variables.ALGORITHM SWAPvar1 = 10var2 = 20temp = 0temp = var1 "temp = 10"var1 = var2 "var1 = 20, originally 10"var2 = temp "var2 = 10, originally 20"END SWAP


What are the two types of variables?

The two types of variables are the CONSTANT and CONTROL.


What is the purpose of swapping?

Swapping was an older form of memory management. It was moving from/to secondary storage a whole program at a time, in a scheme known as roll-in/roll-out. Now swapping is a fairly close synonym of paging.


What is an equation made with two variables called?

An equation with two variables . . . seriously!An equation with one variable can be can be solved, but when there are two variables, you need two equations. This is called a system of two equations in two variables.Three equations in three variables, etc.