diff options
| author | Yana Blashchishina <[email protected]> | 2024-01-25 16:08:57 -0800 |
|---|---|---|
| committer | Yana Blashchishina <[email protected]> | 2024-01-25 16:08:57 -0800 |
| commit | 9e0a0614f351d122bd364ee72678306dd7593403 (patch) | |
| tree | 011531615973d7742c09e87c20ff235c5c8615fd | |
| parent | init (diff) | |
| download | in-class-exercise-6-yanablash-9e0a0614f351d122bd364ee72678306dd7593403.tar.xz in-class-exercise-6-yanablash-9e0a0614f351d122bd364ee72678306dd7593403.zip | |
| -rw-r--r-- | InClassExercise6/InClassExercise6/helper.h | 10 | ||||
| -rw-r--r-- | InClassExercise6/InClassExercise6/source.cpp | 113 |
2 files changed, 123 insertions, 0 deletions
diff --git a/InClassExercise6/InClassExercise6/helper.h b/InClassExercise6/InClassExercise6/helper.h index be365a4..2a2e075 100644 --- a/InClassExercise6/InClassExercise6/helper.h +++ b/InClassExercise6/InClassExercise6/helper.h @@ -13,6 +13,16 @@ float FtoC(int fah); float CtoF(int cel); + +int math_func(); + +int math_func(int square); + +int math_func(int a, int b); + +int math_func(int A, int B, int C, int x =2); + + long factorical(int a); #endif // MY_HEADER_FILE_H
\ No newline at end of file diff --git a/InClassExercise6/InClassExercise6/source.cpp b/InClassExercise6/InClassExercise6/source.cpp index d2f30bd..decf3cf 100644 --- a/InClassExercise6/InClassExercise6/source.cpp +++ b/InClassExercise6/InClassExercise6/source.cpp @@ -2,3 +2,116 @@ // Date: 01/25/2024 // Class: CST116 // Assignment: Exercise 6 + +#include <iostream> + +#include "helper.h" + + +int main() +{ + + + + //std::cout << sum(15, 30) << std::endl; + /*std::cout << returnInt() << std::endl; + std::cout << percentage(10, 100) << "%" << std::endl; + std::cout << percentage(25, 100) << std::endl; + std::cout << percentage(30, 300) << std::endl; + std::cout << percentage(780, 100) << std::endl; + int i; + std::cin >> i; + std::cout << FtoC(i) << std::endl; + std::cout << CtoF(i) << std::endl;*/ + //std::cout << sum(10, 15, 32, 56); + //std::cout << sum(15); + //sum(sum1, sum(65, 25)); + + + std::cout << math_func() << std::endl; + std::cout << math_func(2) << std::endl; + std::cout << math_func(2, 4) << std::endl; + std::cout << math_func(5, 7, 8) << std::endl; + + + return 0; +} + + + +int math_func() { + return 1; +} + +int math_func(int square) { + return square * square; +} + +int math_func(int a, int b) { + return a + b; +} + +int math_func(int A, int B, int C, int x) { + return (A * x * x) - (B * x) + C; +} + + + + + + + +int sum(float a) { + return a * 10; +} + +int sum(int a, int b) +{ + int sum = 0; + + sum = a + b; + + return sum; + +} + +int returnInt() { + + return 10; +} + + +float percentage(int a, int b) { + + float perc = (static_cast<float>(a) / b) * 100; + + + return perc; +} + +float FtoC(int fah) { + // -31*5/9 + + float num = (fah - 32) * (5.0 / 9.0); + + return num; +} + +float CtoF(int cel) { + // 9/5+32 + + float num = (cel * (9.0 / 5.0)) + 32; + + return num; +} + + +long factorial(int a) +{ + if (a == 0 || a == 1) + return 1; //base case returns solid data + else + return a * factorial(a - 1); //recursive case: a! = a * (a- 1)! + + +}
\ No newline at end of file |