Swapping variables is accomplished using a temporary variable. For example, if A and B are integers, you can swap their values using the following code:
// Initialize A and B
int A = 5;
int B = 7;
// Create our temporary variable
int temp;
// Perform the swap
temp = A;
A = B;
B = temp;
// Print the results
cout << "A: " << A << " B: " << B << endl;
/*mycfiles.wordpress.com
Exchange of value of 2 variable with temporary variable*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,temp;
clrscr();
printf("\nEnter the value for a & b");
scanf("d",&a,&b);
temp=a;
a=b;
b=temp;
printf("\na=%d",a);
printf("\nb=%d",b);
getch();
}
temp = x; x = y; y = temp;
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
Variables are items, which change their values during the execution of a program. Constants do not change the value during the execution of a program.
Variables are storage areas that hold data that can vary during the execution of a program. A symbolic name is the name given to any entity in a program, including variables, constants, functions, procedures and various other stuff.
void main() { //variable declaration int a; int b; printf("\n Enter the first value"); scanf("%d",&a); printf("\n Enter the second value"); scanf("%d",&b); a=a+b; b=a-b; a=a-b; printf("\n After swap the value"); printf("\n value of A=%d",a); printf("\n value of A=%d",b); getch(); }
temp = x; x = y; y = temp;
Constants are values that remain constant and cannot be changed once they are assigned a value. Variables, on the other hand, can have different values assigned to them and their value can be changed throughout the program. Constants provide a fixed value, while variables provide flexibility and allow for changes in value.
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
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
Variables are items, which change their values during the execution of a program. Constants do not change the value during the execution of a program.
the value of variables is determined by the equation, discrete variables have absolute single value while the continuos have a range value
No, but eliminating variables is one of several ways to find the value of variables in a system of equations.
Independent variables are the input value of a function (usually x) and dependent variables are the output value of the function (usually y).
A variable is a quantity which changes its value through out the program or its lifetime. But a constant is a quantity which does not change its value through out its life time. There are 5 basic constants.
constant is does not change the value of during the excution of programvariable it changes the value during the excution of program
Variables are storage areas that hold data that can vary during the execution of a program. A symbolic name is the name given to any entity in a program, including variables, constants, functions, procedures and various other stuff.
void main() { //variable declaration int a; int b; printf("\n Enter the first value"); scanf("%d",&a); printf("\n Enter the second value"); scanf("%d",&b); a=a+b; b=a-b; a=a-b; printf("\n After swap the value"); printf("\n value of A=%d",a); printf("\n value of A=%d",b); getch(); }