Quiz - 10 on switch in C

Quiz
•
Computers
•
12th Grade
•
Medium
Michael Kona
Used 5+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
What is the syntax for a switch statement in C?
switch { case constant1: // statements break; case constant2: // statements break; default: // default statements }
switch(expression) { case constant1: // statements break; case constant2: // statements break; case constant3: // statements break; default: // default statements }
switch(expression) { case constant1: // statements break; case constant2: // statements break; default: // default statements }
switch(expression) { case constant1: // statements break; case constant2: // statements break; default: // default statements }
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of a switch statement in C?
To handle exceptions in the program
To calculate mathematical operations
To control the flow of the program based on the value of a variable.
To print text on the screen
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output of the following code:
#include
Four
Three
One
Two
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a common mistake to avoid when using a switch statement in C?
Not providing a 'case' for all possible values
Forgetting to include a 'break' statement
Including multiple 'default' cases
Using 'if-else' statements instead
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a switch statement, what happens if a break statement is omitted?
The switch statement will automatically insert a break at the end of the block
The switch statement will throw an error
The control will fall through to subsequent cases until a break is encountered or the switch statement ends.
The switch statement will skip to the default case
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the default case used for in a switch statement?
It is used to specify the data type of the switch statement variable.
It is used to provide an alternative condition for the switch statement.
It is used to define the starting point of the switch statement.
It is used as a catch-all option.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output of the following code:
#include
Pass
Good
Average
Excellent
Create a free account and access millions of resources
Similar Resources on Wayground
12 questions
Bab 1.4.2 - Operator Hubungan dan Operator Logikal dlm Struktur

Quiz
•
9th - 12th Grade
11 questions
Dante Level 1 - Chapter 6 - Dante Ports & Connections

Quiz
•
12th Grade
12 questions
Quiz de Programmation en Langage C

Quiz
•
12th Grade
15 questions
Quiz - 4 on Increment & decrement operators in C

Quiz
•
12th Grade
15 questions
Quiz - 9 on if-else

Quiz
•
12th Grade
20 questions
IT Essentials Computer Connectors and Power

Quiz
•
10th - 12th Grade
20 questions
Phishing quiz

Quiz
•
1st - 12th Grade
10 questions
PROGRAMACION

Quiz
•
9th Grade - University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade