Answer to Question #327318 in C++ for ness

Question #327318

The Positive Ones

by CodeChum Admin

There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.


Go and search for the positive ones among these four!



1
Expert's answer
2022-04-11T13:18:25-0400
#include<iostream>
#include<vector>


using namespace std;


int main()
{
	const int N = 4;
	vector<int>v;
	int arr[N];
	cout << "Please, enter four numbers: ";
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < N; i++)
	{
		if(arr[i]>0)
			v.push_back(arr[i]);
	}
	cout << "Positive numbers are ";
	for (int i = 0; i < v.size(); i++)
	{
		cout<<v[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
APPROVED BY CLIENTS