Put more than one expression on a line, using the comma as a sequence point. - C++ Operator

C++ examples for Operator:Comma Operator

Description

Put more than one expression on a line, using the comma as a sequence point.

Demo Code

#include <iostream>
using namespace std;
int main()//w w w  . j  av  a  2s  . c  o  m
{
   int num, sq, cube;
   num = 5;
   // Calculate the square and cube of the number.
   sq = (num * num), cube = (num * num * num);
   cout << "The square of " << num << " is " << sq <<
   " and the cube is " << cube;
   return 0;
}

Result


Related Tutorials