diff options
| author | raquelc <[email protected]> | 2024-02-04 14:11:39 -0800 |
|---|---|---|
| committer | raquelc <[email protected]> | 2024-02-04 14:11:39 -0800 |
| commit | fdbef4298342a6f41aa2f315d0f2dd0d5d718d48 (patch) | |
| tree | 6913d0f03080b1ea4ece011ab35bb4a9d737fe06 | |
| parent | setup of pages hmw4 (diff) | |
| download | homework-4-raquel191-fdbef4298342a6f41aa2f315d0f2dd0d5d718d48.tar.xz homework-4-raquel191-fdbef4298342a6f41aa2f315d0f2dd0d5d718d48.zip | |
completed homework 4
| -rw-r--r-- | Homework-4/Homework-4/program.cpp | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/Homework-4/Homework-4/program.cpp b/Homework-4/Homework-4/program.cpp index bbf0ef5..aa882a6 100644 --- a/Homework-4/Homework-4/program.cpp +++ b/Homework-4/Homework-4/program.cpp @@ -8,7 +8,85 @@ using std::cin; using std::cout; using std::endl; + +int Print() { + for (int i = 0; i <= 100; i++) { + cout << i << " "; + } + return 0; +} + +struct { + int month ; + int day; + int year; +}mystruct; + +long PrintFibonacci(size_t n) { + if (n <= 1) + return n; + return PrintFibonacci(n - 1) + PrintFibonacci(n - 2); +} + int main() { + + + char letter_ent = 0; + //cin >> letter_ent; + while (letter_ent != 'D') { + + cout << "Select one of the following options: " << endl; + cout << "A. Print 100" << endl; + cout << "B. Input personal info" << endl; + cout << "C Print Fibonacci" << endl; + cout << "D. Exit " << endl; + + cin >> letter_ent; + + switch (letter_ent) { + case 'A': + Print(); + cout << endl; + break; + + case 'B': + cout << "Enter you birth day: " << endl; + int m; + cout << " month(MM): "; + cin >> m; + mystruct.month = m; + + int d; + cout << " day(DD): "; + cin >> d; + mystruct.day = d; + + int y; + cout << " year(YYYY): "; + cin >> y; + mystruct.year = y; + + cout << mystruct.month << " / " << mystruct.day << " / " << mystruct.year << endl; + break; + + case 'C': + int a, n; + cin >> n; + for (a = 0; a < n; a++) + cout << PrintFibonacci(a) << " " ; + cout << endl; + break; + + case 'D': + cout << "End of program"; + break; + default: + cout << "Error" << endl; + } + + } + return 0; -}
\ No newline at end of file +} + |