Professional Documents
Culture Documents
C Programming Lecture - 6
C Programming Lecture - 6
Abdulkareem V
vabdulkareemv@gmail.com
Largest of 3 numbers
else-if construction
Bitwise Operators
Bitwise AND
Bitwise OR
Bitwise XOR
I Variable Declaration
I Constants in C
I Arithmetic Operators
I if-else statement
I Equality Operators
I Relational Operators
I Logical Operators
I In code 1 the else part is associated with the inner if (if(x > 0))
I In code 1 the else part is associated with the inner if (if(x > 0))
I If that isn’t what you want, braces must be used to force the
proper association as in code 2
I In code 1 the else part is associated with the inner if (if(x > 0))
I If that isn’t what you want, braces must be used to force the
proper association as in code 2
I This kind of bug can be hard to find; it’s a good idea to use
braces when there are nested ifs.
Abdulkareem V | C Programming - Lecture 6
Home Work
6
return 0 ;
}
return 0 ;
}
return 0 ;
}
return 0 ;
}
return 0 ;
}
return 0 ;
}
return 0 ;
}
return 0 ;
}
Syntax
if(expression)
statement
else if(expression)
statement
else if(expression)
statement
...
else
statement;
Syntax
if(expression)
statement
else if(expression)
statement
else if(expression)
statement
...
else
statement;
I The expressions are evaluated in order. If an expression is true,
the statement associated with it is executed, and this terminates
the whole chain.
Syntax
if(expression)
statement
else if(expression)
statement
else if(expression)
statement
...
else
statement;
I The expressions are evaluated in order. If an expression is true,
the statement associated with it is executed, and this terminates
the whole chain.
I Each statement is either a single statement, or a block of them
Abdulkareem V | C Programming - Lecture 6
Bitwise Operators
20