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.
E.g.:
int pr, rt;
float amt;

Arithmetic instructions 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.

Example 1:
int a = 5, b = 10, c;
c = a + b;
Here,
a, b and c are called operands
=, + are called as operators

Example 2:
int a;
float b, c, d;
a = 10;
b = 0.05;
c = 1.5;
d = a +b * c;
Here,
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 instruction is 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:
1) The if statement
2) The if-else statement
3) The conditional operators
4) The switch statement


Responses

0 Respones to "Instructions in C Programming Language"

Post a Comment

 

Total Pageviews

Return to top of page Copyright © 2011 | Kuppam Engineering College Converted into Blogger Template by Mohan Murthy