diff options
| author | Asahel <[email protected]> | 2024-02-05 20:36:38 -0800 |
|---|---|---|
| committer | Asahel <[email protected]> | 2024-02-05 20:36:38 -0800 |
| commit | f36aaa30b426828644a775b72a5722b35ee71375 (patch) | |
| tree | 43bb60438c1343edf1e6041d706170952742f0cd /Homework 4/program.cpp | |
| parent | Implemented a forloop solution. (diff) | |
| download | homework-4-asahellt-f36aaa30b426828644a775b72a5722b35ee71375.tar.xz homework-4-asahellt-f36aaa30b426828644a775b72a5722b35ee71375.zip | |
Diffstat (limited to 'Homework 4/program.cpp')
| -rw-r--r-- | Homework 4/program.cpp | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/Homework 4/program.cpp b/Homework 4/program.cpp index c851742..87d59e4 100644 --- a/Homework 4/program.cpp +++ b/Homework 4/program.cpp @@ -15,28 +15,80 @@ void Print() { cout << i << " "; } } - int main() { - cout << "A. Print(100)" << endl; - cout << "B. Input Personal Information" << endl; - cout << "C. Print Fibonacci" << endl; - cout << "D. Exit" << endl; +void InputPersonalInfo() { + int i = 0; + do { + cout << i << "\n"; + i++; + } while (i < 5); +} + +int fib(int n) { + + if (n <= 1) + return n; +return fib(n - 1) + fib(n - 2); +} - char input = 'A'; +int main() { + + cout << "A. Print(100)" << endl; + cout << "B. Input Personal Information" << endl; + cout << "C. Print Fibonacci" << endl; + cout << "D. Exit" << endl; + + char input = 'A'; + + switch (input) { + case 'A': + Print(); + break; + } + + InputPersonalInfo(); { - switch (input) { - case 'A': - Print(); - break; - } - int month; int day; int year; - cout << "Enter your date of birth"; - cin >> month >> day >> year; + cout << "Enter the month you were born in" << endl; + cin >> month; + + + cout << "Enter the day you were born in" << endl; + cin >> day; + + + cout << "Enter the year you were born in" << endl; + cin >> year; + + + cout << "You were born in: " << month << " " << day << " " << year << endl; return 0; - }
\ No newline at end of file + } + + + int fib(int n);{ + + int n = 9; + cout << n << fib(n); + + + return 0; + } + + + + + return 0; +} + + + + + + + |