← Quiz: C++ Introduction: all 10 questions
Quiz: C++ Introduction · Question 8 of 10
What does this print? (code)
What does this print?
#include <iostream>
using namespace std;
int main() {
bool ok = 5;
cout << ok << " " << boolalpha << (3 > 7) << "\n";
return 0;
}
- A.5 false
- B.true 0
- C.1 false
- D.1 0
Answer & explanation
Correct answer: 1 false
Any non-zero value becomes true, which prints as 1; after boolalpha, false prints as the word false.
Can you get the rest right without peeking?
Take the timed Quiz: C++ Introduction quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →