Skip to content
Quiz · Conditions · lesson 2 of 6

Quiz — which if owns the else

What does the program print?

C++
#include <iostream>

int kind(int x) {
    if (x > 0)
        if (x > 10)
            return 2;
    else
        return -1;
    return 1;
}

int main() { std::cout << kind(5) << ' ' << kind(-5); }