Multiple choice

Which statement is used to print '+' before positive numbers?

  1. cout.setf(+);

  2. cout.setf(showpos);

  3. cout.setf(ios::printpos);

  4. cout.setf(ios::showpos);

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The statement cout.setf(ios::showpos) is used to print + before any positive number. For example, cout<< 5 will display +5.