Question: Consider carefully the program fragment below: bool p; ... if (p == true) cout < < p is true ; else cout < < p

Consider carefully the program fragment below:

bool p; ... if (p == true) cout << "p is true "; else

cout << "p is false ";

Which of the following are valid rewrites of the above? (More than one may be valid)

A. bool p; ... p? (cout << "p is true ") : (cout << "p is false ");

B. bool p; ... cout << "p is " << p << endl;

C. bool p; ... cout << "p is " << (p? "true" : "false") << endl;

D. bool p; ... if (p) cout << "p is true "; else cout << "p is false ";

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!