Add complete assignment and starter code.

This commit is contained in:
Rob Hess
2019-04-17 16:46:07 -07:00
commit 31de8c902f
14 changed files with 461 additions and 0 deletions

27
example_output/p1.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include <iostream>
int main() {
double circle_area;
double circle_circum;
double pi;
double r;
double sphere_surf_area;
double sphere_vol;
/* Begin program */
pi = 3.1415;
r = 8.0;
circle_area = pi * r * r;
circle_circum = pi * 2 * r;
sphere_vol = (4.0 / 3.0) * pi * r * r * r;
sphere_surf_area = 4 * pi * r * r;
/* End program */
std::cout << "circle_area: " << circle_area << std::endl;
std::cout << "circle_circum: " << circle_circum << std::endl;
std::cout << "pi: " << pi << std::endl;
std::cout << "r: " << r << std::endl;
std::cout << "sphere_surf_area: " << sphere_surf_area << std::endl;
std::cout << "sphere_vol: " << sphere_vol << std::endl;
}

34
example_output/p2.cpp Normal file
View File

@@ -0,0 +1,34 @@
#include <iostream>
int main() {
double a;
double b;
double x;
double y;
double z;
/* Begin program */
a = true;
b = false;
x = 7;
if (a) {
x = 5;
if (b) {
y = 4;
} else {
y = 2;
}
}
z = (x * 3 * 7) / y;
if (z > 10) {
y = 5;
}
/* End program */
std::cout << "a: " << a << std::endl;
std::cout << "b: " << b << std::endl;
std::cout << "x: " << x << std::endl;
std::cout << "y: " << y << std::endl;
std::cout << "z: " << z << std::endl;
}

35
example_output/p3.cpp Normal file
View File

@@ -0,0 +1,35 @@
#include <iostream>
int main() {
double f;
double f0;
double f1;
double fi;
double i;
double n;
/* Begin program */
n = 6;
f0 = 0;
f1 = 1;
i = 0;
while (true) {
fi = f0 + f1;
f0 = f1;
f1 = fi;
i = i + 1;
if (i >= n) {
break;
}
}
f = f0;
/* End program */
std::cout << "f: " << f << std::endl;
std::cout << "f0: " << f0 << std::endl;
std::cout << "f1: " << f1 << std::endl;
std::cout << "fi: " << fi << std::endl;
std::cout << "i: " << i << std::endl;
std::cout << "n: " << n << std::endl;
}