100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary CS 31 Worksheet Week 4 Concepts While Loops, Do While Loops, String Traversal, Functions. $8.49   Add to cart

Summary

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

 1 view  0 purchase
  • Course
  • Institution

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

Preview 2 out of 7  pages

  • January 17, 2022
  • 7
  • 2021/2022
  • Summary
avatar-seller
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 | kamandeabigael@gmail.com
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 | kamandeabigael@gmail.com
Distribution of this document is illegal

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Farider. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

77254 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling

Recently viewed by you


$8.49
  • (0)
  Add to cart