Comprog 2
Comprog 2
LEARNING C
Operators in C
+ Addition
Hierarchy of Operators
PRECEDENCE OF OPERATORS (Arithmetic operators only)
/ Division “
% Modulo “
+ Addition “
- Subtraction “
Types of Operators
Relational Operators
are symbols that are used to test the relationship
between two variables or between a variable and a
constant.
Operator Meaning
> Greater than
>= Greater than or Equal to
< Less than
<= Less than or Equal to
== Equal to
!= Not equal to
Types of Operators
Logical Operators
Logical Operators are symbols that are used to
combine or negate expressions containing relational
operators.
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
BASIC I/O Statements in C
For ouput:
printf() function
ex. printf(“Enter your age:”);
For input:
scanf() function
ex. scanf(“%d”, &age);
Types of Operators
Assignment Operators
a-=b a=a-b
a * =b a=a*b
a*=b+c a = a * ( b+ c)
a%=b a=a%b
a*=a a=a*a