Discover the problem of the following line of codes:
for (int i = 1; i<=2; ++i)
CSC126_Chapter4_Part1

Quiz
•
Computers
•
University
•
Medium
TS ZAKARIA
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The loop condition i=<2 should be i<=2
The semicolons should be changed to commas.
The update statement ++i should be changed to i++
There should be a semicolon at the end of the for statement.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following for loop causes an infinite loop?
for (int i=0; i<10; i--)
{
cout << i;
}
for (int i=0; i<10; i+=2)
{
cout << i;
}
for (int i=10; i>0; i--)
{
cout << i;
}
for (int i=0; i>10; i+=2)
{
cout << i;
}
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the main purpose of a repetition structure?
To store data in a specific order
To execute a single instruction
To repeat one or more instructions until a condition is met
To control user input
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is NOT a basic type of repetition structure in C++?
for loop
while loop
switch loop
do…while loop
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a Loop Control Variable (LCV)?
A function to print output
A variable that controls the flow of the program
A component to read user input
A syntax for conditional looping
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Where is the LCV placed in a for loop statement?
Inside the function block
In the parameters of the for loop (initialization, condition, update)
Outside the main function
Only inside void functions
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How many times will the following code print *?
for(int i=1; i<=3; i++) cout << "*";
2
3
4
0
Create a free account and access millions of resources
Similar Resources on Quizizz
9 questions
Lenguaje de Programación C++. Parte 1.

Quiz
•
University
15 questions
EDA PARTE 2

Quiz
•
University
15 questions
FOP - RECAP CHAP 3

Quiz
•
University
15 questions
C programming

Quiz
•
University
10 questions
LOOPS IN C++

Quiz
•
10th Grade - University
14 questions
Java Operators

Quiz
•
University
10 questions
Quiz 8: Arrays&Vector

Quiz
•
University
15 questions
Quiz 2 - CS110

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade