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
39 lines (32 loc) · 1.03 KB
/
01.cpp
File metadata and controls
39 lines (32 loc) · 1.03 KB
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
//============================================================================
// Name : 01.cpp
// Author : Ak0s
// Description : Exam - task 1
//============================================================================
#include <iostream>
using namespace std;
bool bigger_or_equal(int array[], int length, int number);
int main() {
int array[] = {3, 2, 4, 6, -1};
int length = sizeof(array)/sizeof(int);
int number;
cout << "Which number do you search for in the array?" << endl;
cin >> number;
if (bigger_or_equal(array,length,number) == 0) {
cout << "There isn't any equal or bigger number than the given number in the array!";
}
else {
cout << "There is an equal or bigger number(s) than the given number in the array!";
}
return 0;
}
bool bigger_or_equal(int array[], int length, int number) {
bool bigger_or_equal = false;
for (int i = 0; i < length; i++) {
if (array[i] == number || array[i] > number) {
bigger_or_equal = true;
break;
}
}
return bigger_or_equal;
}