diff options
| author | austinsworld15 <[email protected]> | 2021-10-19 20:47:39 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-19 20:47:39 -0700 |
| commit | 8ed1e3b8d05c01912113f5ebe19fd64c2e614c68 (patch) | |
| tree | 43400cb0332d03ac276128d0ff628fa13049662b | |
| parent | Update CST116F2021-Lab3-Guertin.cpp (diff) | |
| download | cst116-lab3-austinsworld15-8ed1e3b8d05c01912113f5ebe19fd64c2e614c68.tar.xz cst116-lab3-austinsworld15-8ed1e3b8d05c01912113f5ebe19fd64c2e614c68.zip | |
Update CST116F2021-Lab3-Guertin.cpp
| -rw-r--r-- | CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp b/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp index 10aa010..20003a5 100644 --- a/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp +++ b/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp @@ -350,3 +350,79 @@ int main() converted_to_even -= 2; } } + +6b 8.4 pg 184 #1 + +1. + +#include <iostream> +#include<iomanip> +#include <stdlib.h> +#include <thread> +#include <string> + +using std::cout; +using std::endl; +using std::string; +using namespace std; + +int main() +{ + int n, i; + float num[100], sum = 0.0, average; + + + cout << "How many assignments do you have in one class?\n\n"; + cin >> n; + + for (i = 0; i < n; ++i) + { + cout << i + 1 << ". Enter Grade: "; + cin >> num[i]; + sum += num[i]; + } + + average = sum / n; + cout << "Your average for each assignment is: " << average << endl; + + return 0; +} + +6c 8.10 pg 192 #3 + +3. + +#include <iostream> +#include<iomanip> +#include <stdlib.h> +#include <thread> +#include <string> + +using std::cout; +using std::endl; +using std::string; +using namespace std; + + +int main() +{ + int n, t1 = 0, t2 = 1, next_term = 0; + + cout << "What is the number you want to count up to in Fibonacci's sequence?\n\n"; + cin >> n; + + cout << "Here is the sequence: " << t1 << ", " << t2 << ", "; + + next_term = t1 + t2; + + while (next_term <= n) + { + cout << next_term << ", "; + t1 = t2; + t2 = next_term; + next_term = t1 + t2; + } + +return 0; + +} |