Answer to Question #348553 in C++ for Hasnat

Question #348553

Create an array of size ten; get input from user, show only odd values in one go and then even values in one go.

1
Expert's answer
2022-06-07T17:38:42-0400
#include <iostream> 

using namespace std; 

int main( ) 
{ 
	int arr[10];

	cout << "Enter numbers of array\n";
	for (int i = 0; i < 10; ++i)
	{
		cin >> arr[i];
	}

	for (int i = 0; i < 10; ++i)
	{
		if (arr[i] % 2 == 0)
		{
			cout << arr[i] << " ";
		}
	}

	cout << "\n";

	for (int i = 0; i < 10; ++i)
	{
		if (arr[i] % 2 != 0)
		{
			cout << arr[i] << " ";
		}
	}

	return 0; 
}

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
APPROVED BY CLIENTS