Types of Instructions on C language
In C language there are basically three types of instructions which are as follows
- Type Declaration Instruction
- Arthimetic Instruction
- Control Instruction
Type Declaration Instruction:
This instruction is used to declare the type of variables used in a C program. Any of the variable is used in the program needs to be declared before using it in any statement. The type declaration statement is started at the beginning of main() function.
There are some fine variations of the type declaration instruction which are as follows
While declaring the type of variable we can initialize it as shown below.
int i = 10, j = 25 ;
float a = 1.5, b = 1.99 + 2.4 * 1.44 ;
The order if variable definition is sometimes very important and sometimes not. e.g.
int i = 10, j = 25 ;
is similar to
int j = 25, j = 10 ;
However,
float a = 1.5, b = a + 3.1 ;
is alright, but
float b = a + 3.1, a = 1.5 ;
is not alright. The reasin behind this is that we are trying to use a even before defining it.
Arithmetic Instruction:
This type of instruction is used to perform arithmetic operations between constants and variables. An arithmetic instruction consists of variable name of the left side of = and variable names and constants on the right side of =. The variables as well as constants which are appearing on the right side of = are connected by arithmetic operators like +,-,* and /.
For example
int ad ;
float kot, deta, alpha, beta, gamma ;
ad = 3600 ;
kot = 0.0076 ;
deta = alpha * beta / gamma + 4.2 * 3 / 7 ;
Here
- *, /, -, + are the arithmetic operators.
- = is the assignment operator.
- 3, 7 and 3600 are integer constants.
- 4.2 and 0.0076 are real constants.
- ad is an integer variable.
- kot, deta, alpha, beta, gamma are real variables.
Control Instruction:
Control instruction is used to control the sequence of execution of various statements in the C program.