C Language

Expressions in C

In C Language by Baqir AliLeave a Comment

Expressions in C

Expressions are meaningful combinations of constants, variables and function calls. Most expressions have both a value and a type. The expression may consist of a single entity, such as a constant or variable, or it may consist of some combination of such entities, interconnected by one or more operators. Expressions can also represent logical conditions which are either true or false.

Example 1:

Several simple expressions are given below:

  a + b

This expression represents the sum of the values assigned to variables a and b.

  x = y

This expression causes the value represented by y to be assigned to x.

Example 2:

t = u + v

In this expression, the value of the expression (u + v) is assigned to t.  It is poor programming practice to mix data types in assignment expressions. Thus, the data types of the constants or variables on either side of the = sign should always match

Expression Statement

An expression statement consists of an expression followed by a semicolon.

Example 3:

area = PI * radius * radius;   – This causes the value of the expression on the right of the equal sign to be assigned to the variable on the left.

Support us by sharing this post

About the Author

Baqir Ali

Facebook Twitter

Hi, I am Baqir Ali ---- Blogger, Programmer, and a Teacher. I am currently working as a Programmer for Softnat Technologies. I have tons of ideas and data to share with you all via blogging.

Leave a Comment