GET EDUCATE

Contents
Basics of C Programming

⯈Basic C Programs

Comma operator in C

  • Symbol of comma operator is ,
  • It has the least precedence.
  • It evaluates all the expressions from LHS to RHS, discards all the results and gives the answer as the rightmost expression value.
  • This operator is also used to separate variable names.
  • This is also used in multiple initializations and multiple updations in for loop.
  • Depending on where the operator is used its behavior changes.

Examples:

a = 3

y = ++a, 10

It evaluates ++a and 10 both but returns the answer as 10.

Therefore,

a = 4

y = 10

Scroll to Top