diff options
| author | Nataliia Brown <[email protected]> | 2024-01-27 12:03:10 -0800 |
|---|---|---|
| committer | Nataliia Brown <[email protected]> | 2024-01-27 12:03:10 -0800 |
| commit | a34f7e186740e7bd11f7b00c7610dc710baa3646 (patch) | |
| tree | 5255ef70b3add7e4366b3128d9764b7d69a25dab /InClassExercise_5 | |
| parent | Initial commit (diff) | |
| download | in-class-exercise-5-natabrown-a34f7e186740e7bd11f7b00c7610dc710baa3646.tar.xz in-class-exercise-5-natabrown-a34f7e186740e7bd11f7b00c7610dc710baa3646.zip | |
Diffstat (limited to 'InClassExercise_5')
| -rw-r--r-- | InClassExercise_5/InClassExercise_5/In_Class_Ex_5.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/InClassExercise_5/InClassExercise_5/In_Class_Ex_5.cpp b/InClassExercise_5/InClassExercise_5/In_Class_Ex_5.cpp index 0aa48a9..eee5788 100644 --- a/InClassExercise_5/InClassExercise_5/In_Class_Ex_5.cpp +++ b/InClassExercise_5/InClassExercise_5/In_Class_Ex_5.cpp @@ -11,42 +11,75 @@ int main() { - return 0 + int mySum = sum(15, 30); + + std::cout << mySum << 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(700,100) << "%" << std::endl; + + + int i; + std::cin >> i; + std::cout << FtoC(i) << std::endl; + std::cout << CtoF(i) << std::endl; + + return 0; } 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) { + float num = ((fah - 32) * (5.0 / 9.0)); - + return num; } float CtoF(int cel) { + float num = (cel * (9.0 / 5.00)) + 32; + return num; } long factorial(int a) { - - + if (a == 0 || a == 1) + { + return 1; + } + else { + return a * factorial(a - 1); + } } |