Instructions & Operators Flashcards
what are instruction in C
these are statements in a program
there are three types of instructions in C
-Type declaration instruction
-Arithmetic instruction
-Control instruction
Type declare instructions
declare variable before using it,you should’nt bring up a variable out of nowwhere
int a=22;
int b=a;
int c=b+1;
int d=1,e;
int a,b,c;
a=b=c=1; you cannot use and declare at the same time do it seperately
Arithmetic instructions
a+b
a-operand
+-operator
type conversion int +int =int
float(4byte)+int(2byte)=float(4 byte)
float+float=float
priority order (operator precedence) in C
*,/,%
+,-
=
assoscitivity rule-Left to right
Control instructions
used to control the flow of instructions in C
they are of four types :
-sequence control-one by one (what we learnt so far)
-decision control-IF ELSE
-loop control-FOR ,WHILE
-case control-
code for the below operations
power(a,b)
modulus(a,b)
include<math.h></math.h>
pow(b,c) which is from math library
int power=pow(a,b);
int modulus=10%3; modulus only works with integer and not on float
what are different types of conversions
implicit-conversion that the computer does on it’s own
int-float,int-double(8byte float)
explicit-external conversion made by the user
int a= (int) 1.999;
what are different types of operators
Arithmetic operator +,-,/,,%
Relational operator ==,>,>=,<,<=,!=
Logical operator && (and), || (or), ! (not)
Bitwise operator
Assignment operator =,+=,-=,=,/=
Ternary operator (shorthand version of if-else ?)
Boolean in C (how True and False represented)
True 1
False 0
printf(“statement is :%d”,3==3);
1
priority order for logical operations
!
*,/,%
+,-
<,<=,>,>=
&&
||
=
not>and>or