100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Tentamen (uitwerkingen)

CS 160 Exam 2 questions with answers

Beoordeling
-
Verkocht
-
Pagina's
11
Cijfer
A+
Geüpload op
14-12-2025
Geschreven in
2025/2026

CS 160 Exam 2 questions with answers

Instelling
CS160
Vak
CS160









Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
CS160
Vak
CS160

Documentinformatie

Geüpload op
14 december 2025
Aantal pagina's
11
Geschreven in
2025/2026
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

CS 160 Exam 2 questions with answers
|\ |\ |\ |\ |\ |\




How many iterations (if any)will the following loop make?
|\ |\ |\ |\ |\ |\ |\ |\ |\




for(int a = 0; a < 4; a++) {} - CORRECT ANSWERS ✔✔4
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\




How many iterations (if any)will the following loop make?
|\ |\ |\ |\ |\ |\ |\ |\




for(int b = 5; b >= 0; b--) {} - CORRECT ANSWERS ✔✔6
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\




How many iterations (if any)will the following loop make?
|\ |\ |\ |\ |\ |\ |\ |\




for(int c = 25; c > 45; c+= 5) {} - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



✔✔0


How many iterations (if any)will the following loop make?
|\ |\ |\ |\ |\ |\ |\ |\




for (int d = 0; d <= 17; d += 3) {} - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



✔✔6


while (true) {} - CORRECT ANSWERS ✔✔infinite
|\ |\ |\ |\ |\ |\




When is it better or preferable to use a while loop instead
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



of a for loop? - CORRECT ANSWERS ✔✔It is better to use a
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



while loop when the number of iterations is not known in
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



advance, such as when dealing with random numbers or |\ |\ |\ |\ |\ |\ |\ |\ |\



type safe user input.
|\ |\ |\

, When is it better or preferable to use a for loop instead of
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



a while loop? - CORRECT ANSWERS ✔✔It is better to use a
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



for loop when the number of iterations is known in
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



advance, such as when processing Strings, lists, or
|\ |\ |\ |\ |\ |\ |\ |\



dealing with input of a fixed size. |\ |\ |\ |\ |\ |\




Write some selection statements for a number guessing
|\ |\ |\ |\ |\ |\ |\ |\



game that can help determine how a user inputted guess
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\



is related to the hidden number. As a part of your solution
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



you can use two int variables with identifiers guess and
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



secretNumber, which you can assume have been |\ |\ |\ |\ |\ |\ |\



previously declared and initialized. Your code should print
|\ |\ |\ |\ |\ |\ |\ |\



out the message "Too high", "Too low", or "Correct" based
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\



on how the guess is related to the secret number. You do
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



not need to worry about reading input or handling
|\ |\ |\ |\ |\ |\ |\ |\ |\



multiple guesses. - CORRECT ANSWERS ✔✔if(guess >
|\ |\ |\ |\ |\ |\ |\



secretNumber) { |\




|\ System.out.println("Too high"); |\ |\




}
else if (guess < secretNumber) {
|\ |\ |\ |\ |\




|\ System.out.println("Too low"); |\ |\




}
else { |\




|\ System.out.rpintln("Correct"); |\




}

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
EXAMSTUDYPLUG Stanford University
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
304
Lid sinds
3 jaar
Aantal volgers
107
Documenten
18112
Laatst verkocht
5 dagen geleden
GRADE BUDDY

Welcome to My Page! Are you looking for high-quality study resources to ace your exams or better understand your coursework? You've come to the right place! I'm passionate about sharing my knowledge and helping students succeed academically. Here, you'll find a wide range of well-organized notes, study guides, and helpful materials across various subjects, including Maths ,nursig, Biology, History, etc.. Each resource is carefully crafted with detailed explanations, clear examples, and relevant key points to help simplify complex concepts. Whether you're preparing for a test, reviewing lectures, or need extra support, my resources are designed to make your learning experience smoother and more effective. Let me be a part of your academic journey, and feel free to reach out if you have any questions or need personalized assistance!

Lees meer Lees minder
4.5

230 beoordelingen

5
155
4
50
3
13
2
5
1
7

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen