by CodeChum Admin
I always want to look at the positive side of things, so I decide to seriously look at positive numbers, too!
Will you code along with me?
Instructions:
Input
Multiple lines containing an integer on each.
2
3
4
-1
-5
1
0
Output
A line containing an integer.
10
#include <iostream>
using namespace std;
int main()
{
int n, ans = 0;
do
{
cin >> n;
if (n > 0) ans++;
} while (n != 0);
cout << ans << '\n';
return 0;
}
Comments
Leave a comment