
C++ For Loop Quiz
Authored by Harshita Kanojia
Computers
University
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of a "for loop" in C++?
To execute code only once
To execute code repeatedly based on a condition
To define a function
To declare a variable
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct syntax for a "for loop" in C++?
for (initialization, condition, increment/decrement) { code }
for (initialization; condition; increment/decrement) { code }
for initialization; condition; increment/decrement { code }
for { initialization; condition; increment/decrement }
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? for (int i = 1; i <= 3; i++) { cout << i << " "; }
1 2 3
1 2 3 4
0 1 2
3 2 1
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a prime number?
A number that is divisible by any number
A number that has only two distinct divisors: 1 and itself
A number that is always even
A number that is always odd
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will the function isPrime(7) return? bool isPrime(int num) { if (num <= 1) return false; for (int i = 2; i <= num / 2; i++) { if (num % i == 0) { return false; } } return true; }
true
false
0
Compilation error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following factorial program do? int factorial = 1; for (int i = 1; i <= 5; i++) { factorial *= i; } cout << factorial;
Calculates the sum of first 5 natural numbers
Calculates 5! (5 factorial)
Prints numbers from 1 to 5
Finds the largest number among 5 numbers
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How many times will the following loop execute? for (int i = 0; i < 5; i++) { cout << i; }
4 times
5 times
Infinite times
6 times
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?
Similar Resources on Wayground
14 questions
DSC119_Chap 2: Data Preparation Methodology and Interface Design
Quiz
•
University
10 questions
104-P-01: Delegates and lambdas
Quiz
•
University
10 questions
System Analysis & Design
Quiz
•
University
11 questions
Recap Chapter 6, 7, 8
Quiz
•
University
13 questions
#include <\c>
Quiz
•
University
10 questions
2024 - Struktur Data Quiz 1
Quiz
•
University
10 questions
Lists
Quiz
•
University
15 questions
Preliminary Round
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
10 questions
Probability Practice
Quiz
•
4th Grade
15 questions
Probability on Number LIne
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
6 questions
Appropriate Chromebook Usage
Lesson
•
7th Grade
10 questions
Greek Bases tele and phon
Quiz
•
6th - 8th Grade
Discover more resources for Computers
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
20 questions
Endocrine System
Quiz
•
University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
30 questions
W25: PSYCH 250 - Exam 2 Practice
Quiz
•
University
5 questions
Inherited and Acquired Traits of Animals
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University
38 questions
Unit 8 Review - Absolutism & Revolution
Quiz
•
10th Grade - University