Computer Science

Expressions & its Types

Definition

The expression is a set of variables and fixed operators written according to the C syntax. In C, each expression returns a value, which means that each expression generates a fixed value of a certain type that can be linked to a variable.

what-is-an-expression

Examples

Some examples of C expressions are shown in the table:

Algebraic Expression C Expression
a x b – c a * b – c
(m + n) (x + y) (m + n) * (x + y)
(ab / c) a * b / c
3x2 +2x + 1 3*x*x+2*x+1
(x / y) + c x / y + c

Types of Expressions

Expressions are the following types:
Types of Expressions
    1. Constant expressions
    2. Integral expressions
    3. Floating expressions
    4. Relational expressions
    5. Logical expressions
    6. Pointer expressions
    7. Bitwise expressions

1. Constant expressions:

A Constant expressions is a statement that is only fixed. Continuous expression can be evaluated in collection rather than during driving, and can be used regularly.
Example:

  • 5 + 7 / 3,
  • 5, 10 + 5 / 6.0, ‘x’

where X and Y are Constant expressions.

2. Integral Expressions:

Integral Expressions is with a specific logical calculation, the numerator and denominator of the result when evaluating the logical expression of a plural are the expressions that are integrated into the numerator and denominator of the refractive index. Logical expression design tests can be performed using two integrated multilayer expression design tests.

Example:

  • x, x * y, x + int ( 5.0)

where x and y are Integral Expressions.

3. Floating expressions:

Floating expressions are the ones that result in a floating comma after all the automatic and clear type changes.Examples:

  • x + y, 6.86
  • X+Y, 89.55

where x and y are floating expression.

4. Relational expressions:

Relation expression produce bool-like results that take on the value of true or false. When calculations are used on both sides of the relational operator, they are first evaluated and then the results are compared. Relationships are also called Boolean expressions.
Examples:
  • x <= y, x + y > 2
  • x<=y, x + y > 54

5. Logical expressions:

A Logical expression combines two or more relational expressions to create a bool type result.
Examples:
  • x > y && x == 54, x == 54 || y == 33
  • x > y &&x == 44, x == 44 || y == 21

6. Pointer expressions:

Pointers expression are used to point to address the location of a variable.
Examples:
  • &x, ytr, ytr++
where x is a variable and ytr is a pointer.

7. Bitwise expressions:

Bitwise expressions are used to work with bitwise data. They are mainly used to test or move parts.
Examples:

x << 9
shifts nine bit position to left

y >> 7
shifts seven bit position to right.

Shift operators are often used for multiplication and division by powers of two

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button