
conditional statements and While Loop
Authored by Fatma Metwally
Information Technology (IT)
University
Used 5+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
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
Given the following code, what would be the output if grade = 85;?
A
B
C
D
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?