URI Online Judge Solution 1060 Positive Numbers using C Programming Language.
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.
Input Sample | Output Sample |
7
-5 6 -3.4 4.6 12 |
4 valores positivos
|
Solution using C :
#include <stdio.h>
int main() {
int i,c=0;
float n[6];
for(i=0; i<6; i++)
{
scanf("%f",&n[i]);
if(n[i]>=0)
c++;
}
printf("%d valores positivos\n",c);
return 0;
}
Comments
Post a Comment