From 8771e43a12d4a704f6a08ed6b16def0686fce30d Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Sat, 27 Jan 2024 15:22:32 -0800 Subject: Inclass 6 overload functions created, problem with math_func() (return 1) will troubleshoot. --- Project1/header.h | 10 ++++------ Project1/inclass6.cpp | 49 ++++++++++++++++++------------------------------- 2 files changed, 22 insertions(+), 37 deletions(-) (limited to 'Project1') 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 @@ -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(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; +} + -- cgit v1.2.3