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 inputted values and print out the result.
Go and search for the positive ones among these four!
#include <iostream>
using namespace std;
int main() {
int x, sum=0;
for (int i=0; i<4; i++) {
cin >> x;
if (x > 0) {
sum += x;
}
}
cout << "The sum of positive number is " << sum << endl;
return 0;
}
Comments
Leave a comment