Skip to content

Combining conditions

Guess the output · 1 of 4

One equals sign

1#include <iostream>
2using namespace std;
3
4int main() {
5 int x = 3;
6 if (x = 5) {
7 cout << "five";
8 } else {
9 cout << "not five";
10 }
11 cout << " " << x << endl;
12 return 0;
13}

What does this print? (Look closely at the if.)