Mathematical Statements and assignments
Within C we can directly load up the variable from within the program using the mathematical expression equates (=) e.g.
a= 'h'; Stores the character h in the variable A
a=1; Stores the number 1 in the variable A
b= 1.00E-10; Stores the number 1x10-10 in B
c = 2.345; Stores the number 2.345 into c
The assignment could be a self replacement type i.e.
A=A+n;
Adds n to the contents of the variable A and replaces the old value in A with the new one .The + operator is a mathematical operator which means add , likewise.
* means multiply
/ means divide
- means subtract
% (remainder of an integer division)
ANSI C allows us to replace the simple formula A = A + n by a condensed version i.e
A+=n; means A = A +n; e.g. a+=3.2 or a+=2;
A-=n; means A = A-n;
Likewise *=, /=, %= also exists. If the element to be subtracted/added is always one then we can use the increment operator (++) and decrement operator (--) i.e. ++A, A--, these can be pre operators and post operators (see loops) i.e. A+=1. Also parentheses (brackets) are used i.e. (). To supplement the C mathematical expressions scientific functions are available. We shall discuss these under the section concerned with functions. We can now construct simple programs using scanf, printf and mathematical functions.