code output to the screen
C++
What does the following segment of code output to the screen (be precise)?
int a = 3;
|
if (a % 2)
cout << "* * * * * * * *\n" ;
cout << "* * * * \n";
a = 4;
if (a % 2)
cout << "* * * * * * * *\n";
cout << "* * * *\n";
int a = 3;
if (a % 2) // if(3%2) -->if(1) --> if(true)
cout << "* * * * * * * *\n" ; // output : * * * * * * * *
cout << "* * * * \n"; //output: * * * *
a = 4;
if (a % 2) // if(4%2) --> if(0) --> if(false)
cout << "* * * * * * * *\n";
cout << "* * * *\n"; //output : * * * *
Step by step
Solved in 2 steps