C++ Conditional Operator Prints 'x' every 8 columns,

Description

C++ Conditional Operator Prints 'x' every 8 columns,

#include <iostream>
using namespace std;
int main()/* w  w  w.  j a va 2s.  co m*/
{
   for(int j=0; j<80; j++)          //for every column,
   {                                //ch is 'x' if column is
       char ch = (j % 8) ? ' ' : 'x';  //multiple of 8, and
       cout << ch;                   //' ' (space) otherwise
   }
   return 0;
}



PreviousNext

Related