Help With Odd/Even Numbers Within Array

Hello, in step 9 of my code, I need to print all the even numbers within the array. I try to divide by two to differentiate my even numbers from my odd. If you need me to go into further detail about my code, feel free to ask! I appreciate all the help.

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//Step 2: Typing my skeleton code
#include <iostream>
#include <string>
using namespace std;
//Function Prototypes
void PrintFirstSetOfValues(double qArray[10]);
double q_Array(double qArray[10]);
void PrintSecondSetOfValues(double qArray[10], double &count);
double ChangeValues(double qArray[10]);
void PrintThirdSetOfValues(double qArray[10]);
void CalculateSum(double qArray[10]);
void EvenOrOdd(double qArray[10], int EvenNumbers[51]);

int main()
{
//Step 3: Declaring my variables 
	double qArray[10]= {3.7, 12.3, 4.5, 10.6, 2.3, 5.4, 9.8, 15.2, 7.7, 19.8};
	int countUp;
	int EvenNumbers[51] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40,
	42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80,
	82, 84, 86, 88, 90, 92, 94, 96, 98, 100};
	double count;
	double sum = 0;
	
	PrintFirstSetOfValues(qArray);
	qArray[10] = q_Array (qArray);
	PrintSecondSetOfValues(qArray,count);
	ChangeValues(qArray);
	PrintThirdSetOfValues(qArray);
	CalculateSum(qArray);
	EvenOrOdd(qArray,EvenNumbers);
	
	return 0;
}
	
void PrintFirstSetOfValues(double qArray[10])
{
	int countUp;
	
	cout<< "\nThe values in the array are as follows: " << endl;
	for(countUp = 0;countUp < 10; countUp++ )
	{
		cout << qArray[countUp] << endl;
	}
	return ;
}
	
//Step 4: Changing the third value in the array to 75.6
double q_Array(double qArray[10])
{
	qArray [2] = 75.6;
	return qArray[2];
}

//Step 5: Displaying all the variables in the array
void PrintSecondSetOfValues(double qArray[10], double &count)
{
	int countUp;
	
	cout<< "\nThe values in the array are now as follows: " << endl;
	for(countUp = 0;countUp < 10; countUp++ )
	{
		cout << qArray[countUp] << endl;
	}
	return;
}


//Step 6: Changing all values under 10.5 to 7.6
double ChangeValues(double qArray[10])
{
	int countUp = 0;

	for(countUp = 0;countUp < 10; countUp++ )
{
	if (qArray[countUp] < 10.5)
		qArray[countUp]= 7.6;
	else qArray[countUp] = qArray[countUp];
}
	return qArray[countUp];
}

//Step 7: Displaying all the variables in the array
void PrintThirdSetOfValues(double qArray[10])
{
	int countUp;
	cout<< "\nThe values in the array are now as follows: " << endl;
	for(countUp = 0;countUp < 10; countUp++ )
	{
		cout << qArray[countUp] << endl;	
	}
	return;
}

//Step 8: Calculating the sum of all the values in the array
void CalculateSum(double qArray[10])
{
	int countUp;
	double sum = 0;
	
	for (countUp = 0; countUp < 10; countUp++)
	{
		sum = sum + qArray[countUp];
	}
	
	cout << "\nThe sum of all the values in the array are: " << sum << endl;
	return;
}


//Step 9: Determining if the values in the array are odd or even
void EvenOrOdd(double qArray[10], int EvenNumbers[51])
{
	int countUp;
		for (countUp = 0; countUp < 10; countUp++)
	{
	if ((qArray[countUp] / 2) == (EvenNumbers[51]))
		
		cout << "The values within this array are even" << endl;
		
	else
		cout << "The values within this array are odd" << endl;
	}
	return;
}
I try to divide by two to differentiate my even numbers from my odd


To give you an idea, you could use the modulo '%' operator to identify the number if it is even or not.
1
2
3
4
5
		if (num % 2 == 0)
			cout << num << " is even.\n";

		else
			cout << num << " is odd.\n";
Topic archived. No new replies allowed.