C Expressions
C Expressions
In this tutorial, we will learn about C Expressions. An expression is a combination of operands, operators, and function calls that resolves or reduces to a single value.
C Expressions
Expressions can be broadly classified into two categories:
- Simple Expressions
- Complex Expressions
Simple Expressions
Simple expressions can be categorized into different types. The expression categories are as follows:
- Primary
- Prefix
- Postfix
- Unary
- Binary
- Ternary
Example
In this example, a and b are operands. The * is an operator. The operator is a multiplication operator that calculates the product of two values. The * operator is a binary operator. It requires two operands for the expression.
The result on the right-hand side (RHS) is a variable. The value of the expression is computed and stored in the variable result.
result = a * b;

If the operand values are:
a = 3;
b = 5;
In this example, a * b is an expression. When calculated it reduces to the value 15.
Code
/**
**********************************
* Program Description:
* C Expressions Demo
* Filename: expr.c
* C Tutorials - www.TestingDocs.com
*************************************
*/
#include<stdio.h>
int main()
{
// declare variables
int a = 3;
int b = 5;
int result = 0;
/* Simple expression */
result = a * b;
printf("Result = %d \n",result);
/* Complex expression */
return 0;
} // end main

Complex Expressions
Complex expressions are expressions formed by one or more simple expressions.
—
C Tutorials
C Tutorials on this website can be found at: