C Comma operator

Description

Comma operator returns the value of the rightmost operand.

Example


#include<stdio.h>
/*w  w  w .ja v a 2s. co  m*/
main(){
    int i, j;
   
    printf("%d",(i = 0, j = 10));

}

The code above generates the following result.

Example 2

You can combine multiple expressions in a single expression using the comma operator.


#include<stdio.h>
/*  w  ww .  jav a 2 s.com*/
main(){
  int i,j,k;
  k = (i = 4, j = 5);
  printf("k = %d",k);
}

The code above generates the following result.





















Home »
  C Language »
    Language Basics »




C Language Basics
Data Types
Operator
Statement
Array