What is Instructions in C
Instructions in C
Q) What do you mean by instruction in C? What are the different types of instructions? Explain each of them with an example.
Instruction of Instructions in C
- A statement written in the C program is known as instruction. It can also be defined as the command of a task given to the computer.
Type of instruction
- There remain basically three types of instructions in C:
- Type declaration instruction
- Arithmetic instruction
- Control instruction
Type declaration instruction
- The instruction is used to declare the type of the variable being used in the program. Each variable used in the program must equal declared before using it in any statement.
- The type declaration statement is written at the beginning of a main() function.
float price = 10.5;
int j = 10, j = 20;
- Here instruction is done to perform arithmetic operations.
- The C arithmetic instruction consists of a variable name on the left-hand side of = and an arithmetic expression on the right-hand side of=
- The variable and constants appearing on the right-hand side of= are connected by arithmetic operators like+,-,* and /.
c = a * b + 5. 5 / 2;
- Because some name suggests the ‘control instructions enable us to specify the order within which the various instructions in each program are to be executed by the computer.
- In other words, some control instructions determine the specific flow of control in a program. There are four types of control instruction in C.
They are Control Instructions:
- Sequence control instruction
- Selection of decision control instruction (if-else)
- Repetition or loop control instruction (While, do-while, for)
- Case-control instruction (switch case)