Skip to content
KALANBLON
Show contents

Chapter 3 of 6 · 10 min

Quiz: deciding

Conditions, logical operators, switch and std::cin: let's check that your program makes the right decisions. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.What does this code display?

    One answer

    int grade = 12;
    if (grade >= 16) {
        std::cout << "Excellent";
    } else if (grade >= 10) {
        std::cout << "Pass";
    } else {
        std::cout << "Fail";
    }
  2. 2.With int x = 7;, which conditions are true? (several answers)

    Several answers possible

  3. 3.The user types "twelve" for int n. What is the value of std::cin >> n in an if?

    One answer

  4. 4.Fill in the blank to read a whole line, spaces included, into address.

    Complete the code

    std::string address;
    std::____(std::cin, address);
  5. 5.After std::cin >> age;, why does std::getline(std::cin, name); return an empty line?

    One answer

  6. 6.Can you write switch (city) with std::string city?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.