11. 4.21 (What Does this Program Do?) What does the
following
program print?
1 // Exercise 4.21: Mystery2.cpp
2 #include <iostream>
3 using namespace std;
4
5 int main() {
6 unsigned int count{1};
7
8 while (count <= 10) {
9 cout << (count % 2 == 1 ? "****" : "++++++++")
<< endl;
10 ++count;
11 }
12 }
OUTPUT :
In this program, The while loop end till equal to,less than 10.
here we use ternary operator in which if the count%2==1 then it will print **** and if not then it will print ++++++++
Get Answers For Free
Most questions answered within 1 hours.