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!
#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]<<" ";
}
}
Comments
Leave a comment