conditional statements and While Loop

conditional statements and While Loop

University

11 Qs

quiz-placeholder

Similar activities

Test de C++ pentru clasa a 10-a

Test de C++ pentru clasa a 10-a

10th Grade - University

15 Qs

S1 - Q1 - 9A

S1 - Q1 - 9A

9th Grade - University

10 Qs

Scratch Pre-knowledge

Scratch Pre-knowledge

3rd Grade - University

15 Qs

Quiz tentang Quizizz

Quiz tentang Quizizz

University

10 Qs

CHÀO MỪNG TÂN SINH VIÊN K.CNTT - Lần 2

CHÀO MỪNG TÂN SINH VIÊN K.CNTT - Lần 2

University

7 Qs

Session 02

Session 02

University

15 Qs

Understanding Loops in C Programming

Understanding Loops in C Programming

1st Grade - University

15 Qs

Quiz 4

Quiz 4

University

10 Qs

conditional statements and While Loop

conditional statements and While Loop

Assessment

Quiz

Information Technology (IT)

University

Hard

Created by

Fatma Metwally

Used 5+ times

FREE Resource

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the output of the following code if int x = 5?

  • Greater than 10

  • 10 or less

  • No output

  • Error

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is wrong with the following code?

  • Missing a semicolon

  • The if condition is missing parentheses

  • == should be =

  • Nothing, the code is correct

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You want to assign a discount based on a customer’s age:

  • Age 0-12: "Child discount"

  • Age 13-18: "Teen discount"

  • Age 19-64: "Adult discount"

  • Age 65 and above: "Senior discount"

Which type of control structure is best suited for this scenario?

  • if

  • if-else if

  • switch

  • while

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Given the following code, what would be the output if grade = 85;?

A

B

C

D

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the output of the following code if int x = 5;?

  • Equal to 10

  • Not equal to 10

  • No output

  • Compilation error

Answer explanation

The condition mistakenly uses = for assignment instead of == for comparison, so x = 10 makes x equal to 10, which is non-zero (true), and the if block executes.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will the following code print if int grade = 75;?

  • Excellent Done

  • Good Done

Good

  • Average Done

Answer explanation

grade is 75, so grade > 70 is true, which makes "Good" print. The final cout << " Done"; is outside the conditions, so "Done" is also printed.

7.

OPEN ENDED QUESTION

3 mins • 1 pt

Write a program that checks if a number is positive, negative, or zero. Display appropriate messages for each case.

Evaluate responses using AI:

OFF

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?