Make this code stop looping once you get the right answer:
string answer;
bool hasGuessed = false;
while(true) {
cin>> answer;
if (answer == “the right answer”){
__________
}
}
C++ While Loops
Quiz
•
Computers, Science
•
6th - 8th Grade
•
Hard
Natalia Fumero
Used 198+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Make this code stop looping once you get the right answer:
string answer;
bool hasGuessed = false;
while(true) {
cin>> answer;
if (answer == “the right answer”){
__________
}
}
hasGuessed == false
hasGussed == true
hasGuessed = true;
hasGuessed = false;
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Make this code loop three times:
in tries= 0;
while(_________ ) {
cin>> “Looping!”;
tries++;
}
tries < 3
answer == 3
tries > 0
tries < 0
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Make this code stop looping when you get the right answer or have no more tries left
string answer;
int tries = 5;
while(_________) {
cin>> answer;
if (answer == “the right answer”){
cout<<“correct”<<endl;
break;
}
tries - - ;
}
tries == answer
tries > 0
tries >= 3
tries <= 5
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of these statements stops a while loop?
stop;
break;
loop pause;
do { }
5.
FILL IN THE BLANK QUESTION
2 mins • 1 pt
Fill in the blank with the right symbol to make this code print Tacos 4 times
int tacos = 4;
while(tacos ___ 0){
cout<<“Tacos”<<endl;
tacos - - ;
}
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Fill in the blank to make this code print Go Heat!
3 times
int loop = 0;
while(__________){
cout<<“Go Heat”<<endl;
loop ++ ;
}
loop < 3
answer == 3
loop = 0
loop == 3
7.
FILL IN THE BLANK QUESTION
1 min • 1 pt
Fill in the blank with the right symbol to make this code print I'm a coder
3 times
int loop = 0;
while(loop __ 3){
cout<<“I'm a coder”<<endl;
loop ++ ;
}
15 questions
Code.org Express Course Quiz 2
Quiz
•
6th - 8th Grade
10 questions
JavaScript Basics
Quiz
•
6th - 8th Grade
20 questions
Python -Iteration (loops)
Quiz
•
7th - 12th Grade
12 questions
Test Cls 7 Sem I
Quiz
•
6th Grade
12 questions
Intro to Scratch 2
Quiz
•
KG - University
12 questions
Ch-8 Iterative statements in Python
Quiz
•
8th Grade
12 questions
C++ References
Quiz
•
6th - 12th Grade
18 questions
Test CLS 7 - Structura alternativă și structurile repetitive
Quiz
•
7th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
12 questions
Dividing Fractions
Quiz
•
6th Grade
9 questions
1. Types of Energy
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
3rd - 6th Grade
43 questions
LinkIt Test - 24-25_BM4_7th
Quiz
•
7th Grade
6 questions
Final Exam: Monster Waves
Quiz
•
6th Grade