C examples for Language Basics:Variable
The assignment operator = assigns a value to a variable.
#include <stdio.h> int main(void) { float x = 3 + 2; }
These operations can be shortened with the combined assignment operators.
#include <stdio.h> int main(void) { int x = 0;/*from w w w . j a v a 2 s .c om*/ x += 5; /* x = x+5; */ x -= 5; /* x = x-5; */ x *= 5; /* x = x*5; */ x /= 5; /* x = x/5; */ x %= 5; /* x = x%5; */ }