forked from Akatakata/zerda-exam-cpp-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01.cpp
More file actions
27 lines (22 loc) · 732 Bytes
/
01.cpp
File metadata and controls
27 lines (22 loc) · 732 Bytes
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
#include <iostream>
using namespace std;
bool biggernum(int array[], int length, int lookfor) {
bool result = false;
for (int i = 0; i < length; i++)
if (array[i] >= lookfor)
result = true;
return result;
}
/**
* Create a function that decides if there is a bigger or equal number than a given number in an array
* It should take the array, it's length and a number as a parameter, then return a boolean
*/
int main() {
int array[] = {3, 2, 4, 6, -1};
int length = sizeof(array) / sizeof(array[0]);
if (biggernum (array, length, 6))
cout << "Found a bigger or equal number than the given number." << endl;
else
cout << "Every number is smaller than the given number." << endl;
return 0;
}