[URI Online Judge] – 1060 – Positive Numbers

Write a program that reads 6 numbers. These numbers will only be positive or negative (disregard null values). Print the total number of positive numbers.

Input

Six numbers, positive and/or negative.

Output

Print a message with the total number of positive numbers.

Sample Input Sample Output
7
-5
6
-3.4
4.6
12
4 valores positivos

Solution:

#include <cstdio>
int main(){
 float n;
 int c = 0;
 while (scanf("%f", &n) != EOF)
 if (n > 0)
 c++;
 printf("%d valores positivos\n", c);
 return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s