Different types of C instructions in C language
What is C instructions : There are basically three types of instructions in c.
- Type Declaration Instruction
- Arithmetic Instruction
- Control Instruction
The Purpose of each of the instructions below
1. Type declaration instruction - to declare the type of variables used in a c program.
2. Arithmetic Instruction - to used perform arithmetic operations between constants and variables.
3. Control Instruction - to Control of the sequence of execute of various statements in a c programs.
1st Learn to c programs would be use only type declaration and Arithmetic Instructions.
Type Declaration Instructions in c
This instruction is used to declare the type of variables being used in the program. variable used in the program must be declared before using it in any statement.
The type of declaration statement is written at the beginning of main() function.
Ex :
int a;
float a,b;
char name;
Declaration instructions type variable another example
Ex :
int a=5,b=10;
float a=1.5,b=2.55;
Arithmetic Instructions in c
c arithmetic instruction consists of a variable name on the left hand side of = and variable name & constants on the right hand side of = the variable and constants appearing on the right side of = are connected by arithmetic operators like +,-,/,*,and %.
Symbol uses :
+,-,/,* are the arithmetic operators.
= assignment operator.
1,2,3 are integer constants.
1.5,2.5,3.5 are real constants.
int a; a- declare to variable.
float a,b,c; a,b,c- declare to real variables.
Example Arithmetic instructions in c programs
#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
printf( "enter the number :");
scanf("%d%d",&a,&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf("The addition operation a an b is %d",c);
printf("The subtract operation a an b is %d",d);
printf("The multiplication operation a an b is %d",e);
printf("The devide operation a an b is %d",f);
}
Control Instructions in c
In The Order of the control instructions determine the flow of control in the programs.There are four types of control instructions in c.
Sequence control instruction - that instructions are executed in the same order in which they appear in the programs.
decision control and case control instructions - the Instructions are allow the computer to take a decision as to which instruction is to be executed next.
Looping or repetition Control instructions - The looping control instruction helps to computer execute a group statements repeatedly.
Type Declaration Instructions in c
This instruction is used to declare the type of variables being used in the program. variable used in the program must be declared before using it in any statement.
The type of declaration statement is written at the beginning of main() function.
Ex :
int a;
float a,b;
char name;
Declaration instructions type variable another example
Ex :
int a=5,b=10;
float a=1.5,b=2.55;
Arithmetic Instructions in c
c arithmetic instruction consists of a variable name on the left hand side of = and variable name & constants on the right hand side of = the variable and constants appearing on the right side of = are connected by arithmetic operators like +,-,/,*,and %.
Symbol uses :
+,-,/,* are the arithmetic operators.
= assignment operator.
1,2,3 are integer constants.
1.5,2.5,3.5 are real constants.
int a; a- declare to variable.
float a,b,c; a,b,c- declare to real variables.
Example Arithmetic instructions in c programs
#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
printf( "enter the number :");
scanf("%d%d",&a,&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf("The addition operation a an b is %d",c);
printf("The subtract operation a an b is %d",d);
printf("The multiplication operation a an b is %d",e);
printf("The devide operation a an b is %d",f);
}
Control Instructions in c
In The Order of the control instructions determine the flow of control in the programs.There are four types of control instructions in c.
- sequence control instruction
- selection or decision control instruction
- repetition or looping control instruction
- case control instruction
Sequence control instruction - that instructions are executed in the same order in which they appear in the programs.
decision control and case control instructions - the Instructions are allow the computer to take a decision as to which instruction is to be executed next.
Looping or repetition Control instructions - The looping control instruction helps to computer execute a group statements repeatedly.
No comments:
Post a Comment