3. Operators:
• An operator is a symbol that tells the compiler to perform a certain
mathematical or logical manipulation.
• Operators are used in programs to manipulate data and variables.
The various types of operators:
1) Arithmetic operators (+, -, *, /, %)
2) Assignment operators (=)
3) Relational /Comparison operators (>, =, <=, ==,!=)
4) Increment and Decrement operators (++, - -)
28/9/2021 A.Chandran ACE Learning Hub, chandkec#gmail.com 3
4. (i)Arithmetic operators:
An arithmetic operator performs mathematical operations such as
addition, subtraction, multiplication, division etc on numerical values
(constants and variables).
28/9/2021 A.Chandran ACE Learning Hub, chandkec#gmail.com 4
8. (iv) Relational or comparison operators:
• Relational operators are used to compare values of two expressions.
Relational operators are binary operators because they require two
operands to operate.
• An expression which contains the relational operators is called
relational expression.
• If the relation is true then the result of the relational expression is
1, if the relation is false then the result of the relational expression
is 0.
28/9/2021 A.Chandran ACE Learning Hub, chandkec#gmail.com 8
12. 28/9/2021 A.Chandran ACE Learning Hub, chandkec#gmail.com 12
Conditional statements in C:
(i) Simple IF statement:
• It contains only the true statement and its condition.
• The statements inside the body of “if” only execute if the given
condition returns true.
• If the condition returns false then the statements inside “if” are
skipped
15. 28/9/2021 A.Chandran ACE Learning Hub, chandkec#gmail.com 15
(ii) IF..Else statements :
• It contains both the true and false statements along with its condition.
IF condition returns true then the statements inside the body of “IF”
are executed and the statements inside body of “else” are skipped.
• IF condition returns false then the statements inside the body of “IF”
are skipped and the statements in “else” are executed.
17. 28/9/2021 A.Chandran ACE Learning Hub, chandkec#gmail.com 17
• In this program user is asked to enter the age and based on the input, the
if..else statement checks whether the entered age is greater than or
equal to 18.
• If this condition is met, then display message “You are eligible for
voting”, however if the condition isn’t met, then display a different
message “You are not eligible for voting”.