diff options
| author | Connor McDowell <[email protected]> | 2024-01-27 15:22:32 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-01-27 15:22:32 -0800 |
| commit | 8771e43a12d4a704f6a08ed6b16def0686fce30d (patch) | |
| tree | 11f517bd40bb50e8e6e60ceb5a45fa9276ef0062 /Project1 | |
| parent | testing two (diff) | |
| download | in-class-exercise-6-connormcdowell275-8771e43a12d4a704f6a08ed6b16def0686fce30d.tar.xz in-class-exercise-6-connormcdowell275-8771e43a12d4a704f6a08ed6b16def0686fce30d.zip | |
Inclass 6 overload functions created, problem with math_func() (return 1) will troubleshoot.
Diffstat (limited to 'Project1')
| -rw-r--r-- | Project1/header.h | 10 | ||||
| -rw-r--r-- | Project1/inclass6.cpp | 49 |
2 files changed, 22 insertions, 37 deletions
diff --git a/Project1/header.h b/Project1/header.h index a172276..de29a83 100644 --- a/Project1/header.h +++ b/Project1/header.h @@ -1,14 +1,12 @@ #ifndef MY_HEADER_FILE_H #define MY_HEADER_FILE_H -int returnInt(); +int math_func(); -int sum(int a, int b); +int math_func(int square = 2); -float percentage(int a, int b); +int math_func(int a, int b); -float FtoC(int fah); - -float CtoF(int cel); +int math_func(int A, int B, int C, int = 2); #endif MY_HEADER_FILE_H
\ No newline at end of file diff --git a/Project1/inclass6.cpp b/Project1/inclass6.cpp index 9f178b6..ead6f80 100644 --- a/Project1/inclass6.cpp +++ b/Project1/inclass6.cpp @@ -1,7 +1,7 @@ // Name: Connor McDowell -// Date: 1/22/2024 +// Date: 1/27/2024 // Class: CST116 -// Assignment: exercise 5 +// Assignment: exercise 6 #include <iostream> @@ -9,55 +9,42 @@ int main() { - int mySum = sum(15, 30); - std::cout << mySum << std::endl; + std::cout << math_func() << std::endl; - std::cout << returnInt() << std::endl; + std::cout << math_func(2) << std::endl; - std::cout << percentage(45, 78) << std::endl; - std::cout << FtoC(120) << std::endl; - std::cout << CtoF(40) << std::endl; - std::cout << returnInt() << std::endl; -} + std::cout << math_func(2, 4) << std::endl; -int returnInt() -{ + std::cout << math_func(5, 7, 8) << std::endl; - return 10; + return 0; } -int sum(int a, int b) +int math_func() { - int sum = 0; - sum = a + b; - return sum; + return 1; } -float percentage(int a, int b) +int math_func(int square) { - int perc = 0; - perc = (static_cast<float>(a) / b) * 100; - return perc; -} + return square * square; +} -float FtoC(int fah) +int math_func(int a, int b) { - // -32*5/9 - float num = (fah - 32) * (5 / 9); - return num; + return a + b; } -float CtoF(int cel) +int math_func(int A, int B, int C, int x) { - // 9/5+32 - float num = (cel * (9.0 / 5.0)) + 32; - return num; -}
\ No newline at end of file + return (A * x * x) - (B * x) + C; +} + |