Answer to Question #285189 in C++ for Francis

Question #285189

I have an array of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the array.


Can you do that for me?


Input

The first line contains the number of elements, n, to be added.

The next line contains the n integers separated by a space.

5
33·54·32·11·8

Output

Multiple lines containing an integer.

2
54
32
8
1
Expert's answer
2022-01-19T16:30:25-0500
#include<iostream>

using namespace std;

int main()
{
	int N;
	cout << "Please, a number of elements: ";
	cin >> N;
	int* arr = new int[N];
	cout << "Enter elements: ";
	for (int i = 0; i < N; i++)
	{
		cin>> arr[i];
	}
	cout << "\nThe even numbers are ";
	for (int i = 0; i < N; i++)
	{
		if (arr[i] % 2 == 0)
			cout << arr[i] << " ";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog