What does the following program print: nested while loop and tenary operator - C++ Operator

C++ examples for Operator:Conditional Operator

Description

What does the following program print: nested while loop and tenary operator

Demo Code

#include <iostream> 
using namespace std; 

int main() //  w w  w . j  av  a2  s  . c om
{ 
    int row = 10; // initialize row 
    int column; // declare column 

    while ( row >= 1 ) // loop until row < 1 
    { 
       column = 1; // set column to 1 as iteration begins 

       while ( column <= 10 ) // loop 10 times 
       { 
           cout << ( row % 2 ? "<" : ">" ); // output 
           ++column; // increment column 
       }

       --row; // decrement row 
       cout << endl; // begin new output line 
    }
}

Result


Related Tutorials