Problem link Click here
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...
#include<stdio.h>
int main()
{
int count=0,n=0;
float a;
while(n!=6){
scanf("%f",&a);
if(a>=0){
count++;
}
n++;
}
printf("%d valores positivos\n",count);
return 0;
}
No comments:
Post a Comment