aboutsummaryrefslogtreecommitdiff
path: root/InClassExercise_5
diff options
context:
space:
mode:
Diffstat (limited to 'InClassExercise_5')
-rw-r--r--InClassExercise_5/InClassExercise_5/In_Class_Ex_5.cpp43
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);
+ }
}