C Instructions.
Hey, learners today we learn about C instructions so if you dontent see my previous posts then, I request you read that post's first then come to this post.
As we all know that program is nothing but basically a set of instructions. With different instructions we can achieve different tasks in a progarm.
Basically there are three types of Instructions:-
1st is the "Type declaration Instruction":
This instruction is used to declare the type of variable used in a C program.
2nd is the "Arithmetic Instruction":
This Instruction is used to perform arithmetic operations on constants and variables.
3rd is the "Control Instruction":
This instruction is used to control the sequence of execution of various statements in a C program.
Let's discuss all this in detail.
1. Type declaration Instruction:
As we all learned at the top, this instruction is used to declare the type of variable used in the program.
This declaration us written at the beginning of main() function.
Example:-
int r;
float d,g;
2. Arithematic Instruction:
Let's learn this with an example.
int bh;
float a,b,c,d,e;
bh=3200;
a=0.0056;
b=c*d/e+3.2*2/5;
In this,
*,/,-,+ are the arithmetic operators.
= is the assignment operator.
2,5 and 3200 are integer constants.
bh is an integer variable.
a,b,c,d,e are real variables.
In common words the variables and constants together are called 'operands'.
The Arithmetic operands are of three types.
1st is "Integer mode arithematic statement" in this, all operands are either integer variables or integer constants.
2nd is "Real mode arithmetic statement" in this, all operands are either real constants or real variables.
3rd is "Mixed mode arithmetic statement" in this. some operands are real and some operands are integers.
Integer and Float Conversions:-
If you want to develop C program efficiently, it is very necessary to understand the rules used for imlicit conversion of floating point and integer values.
Some methods are given below.
(a) An arithematic operation between two integer always yields an integer result.
(b) An arithematic operation between two real always yields a real result.
(c) An operation between an integer and real always yields a real result.
3. Control Instruction:
This instruction is ued to control the order in which the instructions in a program get executed. In short we can also say that, the control instruction determine the "flow of control" in a program.
Basically there are four control instructions in C.
* Sequence control Instruction. (Ensures the instructions are executed in the same order.)
* Case control Instruction. (Allow the computer to take decision.)
* Selection or decision control Instruction. (Allow the computer to take decision.)
* Repetition or loop control Instruction. (Helps to execute a group of statements repeatedly.)
So, That's it for today learners if you don't see previous posts regarding C programming then must see that, before learning this topic for more clarity.
Comments