2. Contents
• Instructions in C
• Assignment Operation
• Arithmetic Instructions
• Rules & Operators Hierarchy
• Decision Control Instructions (If/Else) & Conditional Operators
• Example
3. Instructions in C
• C programming consists of
• Memory Allocation
• Arithmetic
• Logical Statements and Decisions
• Input and Output
4. Assignment operator
• = is termed as assignment operator
• Any statement that contains = is termed as assignment statement
• int a=23; (an integer space is named as a and a value of 23 is kept in it)
• A=‘b’; (A is now equal to character b)
• A=A+3; (new A is equal to old A plus 3)
6. Arithmetic Instructions
• +, -, *, /, % (modulo||reminder),( and )
• + and – has same importance and it doesn’t follow general
mathematic rules for precedence
• * and / as same importance but are more important and has high
precedence value from + and –
• Braces (); has higher precedence than +, -, * and %
• % has used for finding the remainder
• Assignment statement always follow rules from left to right and once
it applies it for a single arithmetic operator. It starts from left again.
9. Logical Instruction
AND(&&), OR(||), NOT(!), EQUAL(==),
NOT EQUAL,(!=) GREATER(>), LESS(<),
LESS OR EQUAL(<=), GREATER OR EQUAL(>=)
are some instruction used for logical decisions and branching.
• Logical instruction are bitwise comparison based
Example:
if(a>=12){//statement to execute}
if(!x){//statement}
if(x!=1000){x=x+1;}
10. If/Else statement in C Programming
• If checks a special condition
• Here inside If, if some condition meets, the next instruction occurs,
else, the compiler neglects the immediate next instruction
• There are four types of conditional statements
• If
• If and else
• If, else if…
• Nested if (anther if inside if)