-
Notifications
You must be signed in to change notification settings - Fork 0
/
array stuff check.cpp
72 lines (54 loc) · 1.51 KB
/
array stuff check.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
#include <iostream>
using namespace std;
int main() {
int array[10];
int evenn=0, oddn=0, positive=0, negative=0, zero=0, prime=0, composite=0, pcheck = 1;
for (int i = 0; i < 10; i++) {
cout<<"Enter number "<<i+1<<": ";
cin>>array[i];
}
cout<<endl;
for (int i = 0; i < 10; i++) {
if (array[i]%2 == 0) {
evenn++;
} else {
oddn++;
}
if (array[i] > 0) {
positive++;
}
if (array[i] < 0){
negative ++;
}
if (array[i] == 0) {
zero++;
}
if(array[i] != 0 && array[i] != 1){
if(array[i] < 0){
pcheck = 0;
}
int j = 2;
j = 2;
int halfofarray = array[i]/2;
for(j = 2;j <= halfofarray; j++){
if (array[i] % j == 0) {
pcheck = 0;
}
}
if(pcheck == 0){
composite++;
} else if(pcheck == 1){
prime++;
}
pcheck = 1;
}
}
cout<<"There are "<<evenn<<" even numbers \n";
cout<<"There are "<<oddn<<" odd numbers \n";
cout<<"There are "<<prime<<" prime numbers \n";
cout<<"There are "<<composite<<" composite numbers \n";
cout<<"There are "<<zero<<" zeros \n";
cout<<"There are "<<positive<<" positive numbers \n";
cout<<"There are "<<negative<<" negative numbers \n";
return 0;
}