Instructions & Operators Flashcards

1
Q

what are instruction in C

A

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-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

code for the below operations

power(a,b)
modulus(a,b)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are different types of conversions

A

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;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are different types of operators

A

Arithmetic operator +,-,/,,%
Relational operator ==,>,>=,<,<=,!=
Logical operator && (and), || (or), ! (not)
Bitwise operator
Assignment operator =,+=,-=,
=,/=
Ternary operator (shorthand version of if-else ?)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Boolean in C (how True and False represented)

A

True 1
False 0

printf(“statement is :%d”,3==3);
1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

priority order for logical operations

A

!
*,/,%
+,-
<,<=,>,>=
&&
||
=

not>and>or

How well did you know this?
1
Not at all
2
3
4
5
Perfectly