aboutsummaryrefslogtreecommitdiff
path: root/Exercise5
diff options
context:
space:
mode:
authorArthur Spears <[email protected]>2024-01-22 19:18:31 -0800
committerArthur Spears <[email protected]>2024-01-22 19:18:31 -0800
commit97a53b9a9c8a4e19c167ff50eeb473b005e1d89c (patch)
treec6617ffd9b22161a4325eb0244223ad4fd1aa887 /Exercise5
parentspacing changes (diff)
downloadarchived-in-class-exercise-5-arthurtspears-97a53b9a9c8a4e19c167ff50eeb473b005e1d89c.tar.xz
archived-in-class-exercise-5-arthurtspears-97a53b9a9c8a4e19c167ff50eeb473b005e1d89c.zip
implemented exercise 5 functions
Diffstat (limited to 'Exercise5')
-rw-r--r--Exercise5/Exercise5/helpers.h14
-rw-r--r--Exercise5/Exercise5/program.cpp46
2 files changed, 58 insertions, 2 deletions
diff --git a/Exercise5/Exercise5/helpers.h b/Exercise5/Exercise5/helpers.h
index c6a1241..0fcb072 100644
--- a/Exercise5/Exercise5/helpers.h
+++ b/Exercise5/Exercise5/helpers.h
@@ -3,8 +3,22 @@
#define MY_HEADER_FILE_H
// Content of the header file
+int returnInt();
+
int sum(int a, int b);
+float percentage(int a, int b);
+
+float FtoC(int fah);
+
+float CtoF(int cel);
+
+
+
+
+
+
+
long factorial(int a);
diff --git a/Exercise5/Exercise5/program.cpp b/Exercise5/Exercise5/program.cpp
index bafa30c..45bfff6 100644
--- a/Exercise5/Exercise5/program.cpp
+++ b/Exercise5/Exercise5/program.cpp
@@ -8,12 +8,22 @@
#include "helpers.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;
-int main()
-{
return 0;
}
@@ -26,6 +36,38 @@ int sum(int a, int 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) {
+ // -32*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)