Ad Code

Responsive Advertisement

Uri - Beecrowd | 1064 | Positives and Average

beecrowd | 1064

Positives and Average

Adapted by Neilor Tonin, URI Brazil


Read 6 values that can be floating point numbers. After, print how many of them were positive. In the next line, print the average of all positive values typed, with one digit after the decimal point.

Input

The input consist in 6 numbers that can be integer or floating point values. At least one number will be positive.

Output

The first output value is the amount of positive numbers. The next line should show the average of the positive values ​typed.

Input Sample Output Sample

7
-5
6
-3.4
4.6
12

4 valores positivos
7.4

N.B.: It's better if you solve this by your own. Thank you!


  URI - BEECROWD Online Judge 1064 Solve  in C :                                          

//Solved by Intesar
#include <stdio.h>

int main() {

    int i,c=0;
    float x,sum=0.0;
    for(i=0;i<6;i++)
    {
        scanf("%f",&x);
        if(x>=0)
        {
            c++;
            sum=sum+x;
        }
    }
    printf("%d valores positivos\n",c);
    printf("%.1f\n",sum/c);

    return 0;
}

Post a Comment

0 Comments

Ad Code

Responsive Advertisement