Answer to Question #326091 in C for blockie

Question #326091

The Positive Ones

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!


Input


1. First number

2. Second number

3. Third number

4. Fourth number

Output

The first four lines will contain message prompts to input the four numbers.

The last line contains the total count of all the positive numbers.

Enter·the·first·number:·2
Enter·the·second·number:·-4
Enter·the·third·number:·3.6
Enter·the·fourth·number:·1
Count·of·positives·=·3





1
Expert's answer
2022-04-08T16:05:24-0400
count = 0


x = float(input("Enter the first number: "))
if x > 0:
    count += 1


x = float(input("Enter the second number: "))
if x > 0:
    count += 1


x = float(input("Enter the third number: "))
if x > 0:
    count += 1


x = float(input("Enter the fourth number: "))
if x > 0:
    count += 1


print('Count of positives =', count

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS