#include <stdio.h>
int main (void)
{
char *first= "Hello";
int second = 12;
printf ("first=%s, second=%d\n", first, second);
return 0;
}
To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;
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;
Use list assignment i.e. for two variables $a, $b: ($a,$b) = ($b,$a)
Yes. int a, b; a= 2; b= 3; a= a+b;
dim a input a
a=a^b; b=a^b; a=a^b;
Assuming that x and y are two variables, such as they might be in Algebra, and that the expression "xy" is meant to be the multiplication of x times y, you would write it as x * y This expression could be used with a third variable in an assignment statement, or as a condition in an if statement where it can be compared to another variable or a constant.
The independent variable is named first. In the Cartesian plane, this means you write (X, Y).
t=x; /* t is the other variable */x=y;y=t;
Variables can maintain the same value throughout a program, or they can change values several times, depending on your needs. when you put a variable in a program, the computer recognises the variable and you can change it's value throughout without an error. Note: You can write programs without variables, but their functionality will be quite restricted, like this: int main (void) { puts ("hello, world"); return 0; }
Certainly, you can write a program without main, but you cannot build an executable from it, if that is okay with you.
int a,b; a=a+b; b=a-b; a=a-b; that's it simple