Skip to content
KALANBLON
Show contents

Chapter 3 of 6 · 10 min

Quiz: deciding

Conditions, logical operators, switch and scanf: let's check that your program knows how to make the right decisions. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.What does this code display?

    One answer

    int x = 15;
    if (x > 10) {
        printf("A\n");
    } else if (x > 5) {
        printf("B\n");
    } else {
        printf("C\n");
    }
  2. 2.Why is if (grade = 20) a mistake?

    One answer

  3. 3.Which conditions are true when age is 30? (several answers)

    Several answers possible

  4. 4.Fill in the blank so that scanf knows where to store the value it reads.

    Complete the code

    int n = 0;
    scanf("%d", ____n);
  5. 5.The user types "abc". What does scanf("%d", &n) return?

    One answer

  6. 6.In a switch, what happens if you forget the break at the end of a case?

    One answer

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