Open Course Lectures - 08-06-2021
Open Course Lectures - 08-06-2021
Expression is
the combination
of operators
and operands.
c= 16 d= 17
Example Program
#include <stdio.h>
int main()
{
int a=7, b=8, c,d;
c=++a+b++;
d=a+++b--;
printf("a=%d and d=%d", c,d);
return 0;
}
Arithmetic Operator %
• It is known as modulus operator. It returns the
integer remainder of a division.
• E.g. 10÷3, Q=3 R=1
• 10 % 3 = 1 //program for sum-of-the-digits of a number
#include <stdio.h>
int main()
{
int a=78,d,sum;
d=a/10;
Sum of the digits=15 a=78%10;
sum=a+d;
printf("Sum of the digits=%d",sum);
return 0;
}
Relational Operators
These are used for comparison of the values of
two operands. For example, checking if one
operand is equal to the other operand or not, an
operand is greater than the other operand or
not etc.
Six Relational operators are (==,!=,>, >= , <, <= )
e.g. A==B, A!=B, A>B, A>=B, A<B,A<=B
Logical Operators
• Logical Operators are used to combine two or more
conditions. The result of the operation of a logical
operator is a boolean value either true or false.
• Logical Opeartors are
• AND represented as ‘&&’
• OR represented as ‘||’
• NOT represented as ‘!’