diff options
| author | Miles-Cell <[email protected]> | 2024-01-31 15:43:06 -0800 |
|---|---|---|
| committer | Miles-Cell <[email protected]> | 2024-02-03 11:35:59 -0800 |
| commit | 0c03e79f3848c97d3fed3b8ed8bac1fff2334ce3 (patch) | |
| tree | 01c8f8cedb193c46eabde1fd7ecdcdaeaf3c26bd /Homework 3 | |
| parent | Homework 3 start, created Source.cpp (diff) | |
| download | homework-3-miles-cell-0c03e79f3848c97d3fed3b8ed8bac1fff2334ce3.tar.xz homework-3-miles-cell-0c03e79f3848c97d3fed3b8ed8bac1fff2334ce3.zip | |
Exercise completed.
Diffstat (limited to 'Homework 3')
| -rw-r--r-- | Homework 3/Homework 3/Header.h | 15 | ||||
| -rw-r--r-- | Homework 3/Homework 3/Homework 3.vcxproj | 3 | ||||
| -rw-r--r-- | Homework 3/Homework 3/Homework 3.vcxproj.filters | 5 | ||||
| -rw-r--r-- | Homework 3/Homework 3/Source.cpp | 30 |
4 files changed, 52 insertions, 1 deletions
diff --git a/Homework 3/Homework 3/Header.h b/Homework 3/Homework 3/Header.h new file mode 100644 index 0000000..8cff6ae --- /dev/null +++ b/Homework 3/Homework 3/Header.h @@ -0,0 +1,15 @@ +#ifndef MAIN_H +#define MAIN_H + +#include <string> + +void printMessage(const std::string& message); +int add(int a, int b); +double multiply(double x, double y); + + + + + +#endif // MAIN_H + diff --git a/Homework 3/Homework 3/Homework 3.vcxproj b/Homework 3/Homework 3/Homework 3.vcxproj index 21d98f8..5805434 100644 --- a/Homework 3/Homework 3/Homework 3.vcxproj +++ b/Homework 3/Homework 3/Homework 3.vcxproj @@ -129,6 +129,9 @@ <ItemGroup> <ClCompile Include="Source.cpp" /> </ItemGroup> + <ItemGroup> + <ClInclude Include="Header.h" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/Homework 3/Homework 3/Homework 3.vcxproj.filters b/Homework 3/Homework 3/Homework 3.vcxproj.filters index 3e7e62e..25c729c 100644 --- a/Homework 3/Homework 3/Homework 3.vcxproj.filters +++ b/Homework 3/Homework 3/Homework 3.vcxproj.filters @@ -19,4 +19,9 @@ <Filter>Source Files</Filter> </ClCompile> </ItemGroup> + <ItemGroup> + <ClInclude Include="Header.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/Homework 3/Homework 3/Source.cpp b/Homework 3/Homework 3/Source.cpp index 8d6f887..7c1c444 100644 --- a/Homework 3/Homework 3/Source.cpp +++ b/Homework 3/Homework 3/Source.cpp @@ -6,19 +6,47 @@ #include <iostream> +#include <string> +using namespace std; +void printMessage(const std::string& message); +int add(int a, int b); +double multiply(double x, double y); +int fibonacci(int n); int main() { + int nthTerm = 10; + int result = fibonacci(nthTerm); + cout << "The " << nthTerm << "th term of the Fibonacci sequence is: " << result << endl; + return 0; +} + + +int fibonacci(int n) +{ + if (n <= 1) + { + return n; + } - return 0; + return fibonacci(n - 1) + fibonacci(n - 2); } +double power(double A, int b) +{ + double x = 1; + for (int i = 0; i < b; ++i) + { + x *= A; + } + return x; +} |