
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
What are types of expressions evaluated in C Language?
An expression is a combination of operators and operands.
Operand is a data item in which operation is performed.
An operator performs an operation on data
For example; z = 3+2*1
z = 5
Types of expressions
The different types of expressions that are evaluated in C language are as follows −
Primary expressions − The operand in this expression can be a name, a constant or any parenthesized expression. For example, c = a+ (5*b);
Postfix expressions − In a postfix expression, the operator will be after the operands. For example, ab+
Prefix expressions − In a prefix expression, the operator is before the operand. For example, +ab
Unary expression − It contains one operator and one operand. For example, a++, --b
Binary expression − It contains 2 operands and one operator. For example, a+b, c-d
Ternary expression − It contains 3 operands and one operator. For example; Exp1? Exp2: Exp3. If Exp1 is true, Exp2 is executed. Otherwise, Exp3 is executed.
Example
Following is the C program for the expressions which are evaluated in C language −
#include <stdio.h> main(){ int a , b; a = 10; printf( "Value of b is %d
", (a == 1) ? 100: 200 );//ternary expression printf( "Value of b is %d
", (a == 10) ? 10: 20 );//ternary expression }
Output
When the above program is executed, it produces the following result −
Value of b is 200 Value of b is 10
- Related Articles
- What are different types of constants in C language?
- What are different types of data in C language?
- What are primary data types in C language?
- What are different operators and expressions used in C language?
- What are the different types of pointers in C language?
- What are the different types of keywords in C language?
- Explain the conversions of expressions of stacks in C language
- Explain the evaluation of expressions of stacks in C language
- Explain different types of expressions in C program
- What are regular expressions in C#
- What are lambda expressions in C#?
- What are the limitations of array in C language?
- What are anchors in regular expressions in C#?
- What are types in C#?
- What are nested structures in C language?
