C instructions and Operators
- Instructions
- Operators
- Type declaration instruction
- Arithmetic instruction
- Control instruction
Type declaration instruction
int a; float
b; int
a=15; float
b=2.5; char messwithage; |
Arithmetic instruction
int a,b,c,d,total; total= (a+b)*c/d Here, +, -, *, and /are arithmetic operater. |
int a = 6, b = -5,remainder;remainder = a/b;
This will give us an output of 1.
int a = -7, b = 5,remainder;
remainder = a/b;
This will give us an output of -2.
Algebraic expression vs C expression
Algebraic |
C |
ab 2x3 (a+b)c |
a*b 2*3 (a+b)*c |
Priority |
Operators |
First |
*, / and % |
Second |
+ and - |
Third |
= |
a = 13*2/3*4+5-4/2+5*2;Order of execution will befirst * a=26/3*4+5-4/2+5*2;second / a=8*4+5-4/2+5*2;third * a=32+5-4/2+5*2;forth / a=32+5-2+5*2;and so on
When the operator of the same priority is present then it will go with the sequence but if there will be bracket() then it will go with bracket.
Conversion of integer and float
- When there will be int and int value it will give output in int.
- When there will be int and float/double value it will give output in float/double.
- When there will be float and float value it will give output in float.
Control instruction
- Sequence control instruction
- Decision control instruction
- Repetition control instruction
- Case-control instruction
In the next article, we will discuss
- If-else statement
- Switch statement
- Relational Operator
- Logical operator
No comments:
Post a Comment
Please do not enter any spam link in the comment box