100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Examen

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

Puntuación
-
Vendido
-
Páginas
7
Grado
A+
Subido en
09-10-2022
Escrito en
2022/2023

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

Institución
Grado

Vista previa del contenido

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

Escuela, estudio y materia

Grado

Información del documento

Subido en
9 de octubre de 2022
Número de páginas
7
Escrito en
2022/2023
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$8.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
haileywangui

Conoce al vendedor

Seller avatar
haileywangui Stanford University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
3 año
Número de seguidores
0
Documentos
141
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes