100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

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

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
02-05-2022
Written in
2022/2023

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

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
May 2, 2022
Number of pages
7
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

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

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
abram23 Adams State College
Follow You need to be logged in order to follow users or courses
Sold
672
Member since
5 year
Number of followers
545
Documents
3368
Last sold
3 months ago
QUALITY WORK OF ALL KIND OF QUIZ or EXAM WITH GUARANTEE OF AN A

Im an expert on major courses especially; psychology,Nursing, Human resource Management &amp; Project writting.Assisting students with quality work is my first priority. I ensure scholarly standards in my documents . I assure a GOOD GRADE if you will use my work.

4.0

141 reviews

5
78
4
25
3
16
2
3
1
19

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions