-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAWorkspace.cpp
72 lines (61 loc) · 1.51 KB
/
AWorkspace.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***********************************************************************************************
* Student name: Andrew Blythe
* Program name: Workspace & Template C++
* Program description: from time at PRCC
* Date:
*************************************************************************************************/
#include <iostream>
#include <iomanip> // input/output manipulation
#include <cstdlib> // Needed to use the exit function
#include <cmath> // maths?
#include <cctype> // Needed for the toupper function
#include <string>
#include <chrono>
#include <windows.h>// Needed to display colors and call Sleep
#include <ctime>
#include <conio.h> // for getch() and pausing
#include <fstream> // Needed to use files
#include <vector> //
#include <climits>
using namespace std;
template <class T>
T min_16(T a, T b)
{
if (a < b)
return a;
else
return b;
}
template <class T>
T max_16(T aa, T bb)
{
if (aa > bb)
return aa;
else
return bb;
}
long long factorial_my(int num)
{
if (num > 1)
return num * factorial_my(num - 1);
else
return 1;
}
int sumArray(int numArr[], int size)
{
if (size == 0)
return 0;
else
return numArr[size-1] + sumArray(numArr, size-1);
}
int main()
{
//call factorial function...
int num;
cout << "enter num: ";
cin >> num;
cout << factorial_my(num) << "\n";
int numbers[5] = {5, 10, 16, 22, 30};
cout << "sum of nums " << sumArray(numbers, 5);
return 0;
}