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
Get step-by-step solutions from verified subject matter experts
