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

CS 31 Worksheet Week 4 Concepts While Loops, Do While Loops, String Traversal, Functions.

Beoordeling
-
Verkocht
-
Pagina's
7
Cijfer
A+
Geüpload op
09-10-2022
Geschreven in
2022/2023

CS 31 Worksheet Week 4 Concepts While Loops, Do While Loops, String Traversal, Functions.

Instelling
Vak

Voorbeeld van de inhoud

Stuvia.com - The Marketplace to Buy and Sell your Study Material




CS 31 Worksheet Week 4
Concepts: While Loops, Do While Loops,
String Traversal, Functions




Downloaded by: Kayyh |
Distribution of this document is illegal

, Stuvia.com - The Marketplace to Buy and Sell your Study Material




CS 31 Worksheet Week 4

This worksheet is entirely optional, and meant for extra practice. Some problems will
be more challenging than others and are designed to have you apply your knowledge
beyond the examples presented in lecture, discussion or projects. Although exams are
online this quarter, it is still in your best interest to practice these problems by hand and
not rely on a compiler.

Solutions are written in red. The solutions for programming problems are not
absolute, it is okay if your code looks different; this is just one way to solve the specific
problem.

If you have any questions or concerns please contact your LA or go to any of the LA
office hours.
Concepts: While Loops, Do While Loops, String Traversal, Functions




m
er as
Reading Problems




co
eH w
1. What does the following code snippet output? What does the call to mystery in
main() return? What does main() return?




o.
#include <iostream>
rs e
ou urc
using namespace std;

int mystery(int a, int b) {
o

int count = 0;
aC s

while (count < 2) {
vi y re


a = a + b/2;
b = a + 5;
cout << "a: " << a << " b: " << b << endl;
count++;
ed d




}
ar stu




return count;
}
int main() {
is




int a = 5, b = 10;
cout << "a: " << a << " b: " << b << endl;
Th




mystery(a, b);
cout << "a: " << a << " b: " << b << endl;
if (a % b == 0) {
sh




return 1;
}
return 0;
}




This study source was downloaded by 100000826342158 from CourseHero.com on 10-06-2021 14:19:00 GMT -05:00


https://www.coursehero.com/file/81070311/CS31-F20-Solutions-Week-4docx/


Downloaded by: Kayyh |
Distribution of this document is illegal

Geschreven voor

Vak

Documentinformatie

Geüpload op
9 oktober 2022
Aantal pagina's
7
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

€7,42
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Maak kennis met de verkoper
Seller avatar
haileywangui

Maak kennis met de verkoper

Seller avatar
haileywangui Stanford University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
0
Lid sinds
3 jaar
Aantal volgers
0
Documenten
141
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

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