Instructions in C Programming Language
There are three types of instructions in C. They are as follows:
1) Type Declaration Instruction
2) Arithmetic Instruction
3) Control instruction
Type Declaration instruction is used to declare the type of variables used in C. Any variable we want to use in the program must be declared before using it. This declaration is done using Type declaration instruction. This declaration is done at the beginning of the main() function.
int pr, rt; float amt;
Arithmetic instructions in C are used to perform arithmetic operations on variables and constants. Here we will learn some new terms. These are operands and operators. The variables and constants on which arithmetic operation is done by arithmetic operators are called operands.
int a = 5, b = 10, c; c = a + b;
a, b and c are called operands
=, + are called as operators
int a; float b, c, d; a = 10; b = 0.05; c = 1.5; d = a +b * c;
a is integer variable.
b, c and d are real variables.
= is the assignment operator.
+ and * are arithmetic operators.
10 is integer constant.
0.05 and 1.5 are real constants.
Control instructions in C are used to control the sequence (flow) of the program.
We write a program to perform a particular task. The program might be addition of two numbers, subtraction of two number or division of two numbers. Let us suppose that we need to write a program to perform all the above three operations i.e. addition, subtraction and multiplication. Writing three different programs is not feasible. If we do so, then for addition, subtraction and division we need to run the program separately. Instead of doing this, we can include decision control statement. Using this we can decide within the program whether to perform addition, subtraction or division. Thus program becomes efficient and user friendly too.
Using decision control statement, we can perform different actions based on the circumstances.
Decision control instructions in C: