Expressions in C with example

Expression is  single data item like number , character or combination of  constants , variables , arrays interconnected by one or more operators.

Several  simple expressions are given below

a + b
x = y
c = a + b
x == y

Types of Expressions in C 

There are different types of expressions in c , they are given below.

1. Arithmetic or Mathematical expression

2. Relational Expression

3. Logical Expression 

4. Conditional Expression 

Arithmetic or Mathematical expressions in C

When two variables or constants are connected by arithmetic operators like +  -  *  / then those expressions are called arithmetic or mathematical expression.

a + b

p - q


p + (q * r) / 2

In C there is similar rule for evaluating mathematical expressions like  bracket  > divide > multiply >  add > subtract.  

Relational Expression in C

when two constants or variables are connected by relational operators < > <=  >=  !=  then those expressions are called as relational expression

a == b

first_number > second_number

i <= 10

Logical Expression in C

When  logical operators are used in expression like && ||  then those expression are logical expressions

(a > b) && (b > c)

(p == q) || (p == r)

Conditional Expression in C

If an expression is made using conditional statement then expression is known as conditional expression

 a*b < 2 ? true : false

we will learn this later in operator chapter in details.

Contact Form


Email *

Message *