Develop a program that asks user to enter a real number. After entering the numbers, the program
should display how many positive, negatives, and zeros were entered by the user. In addition to
that, it should provide information about the majority count either of the entered numbers.
Note : use any loop and avoid to use arrays .
#include <stdio.h>
#include <stdlib.h>
int main(){
int numberOfPositiveValues=0;
int numberOfNegativesValues=0;
int numberOfZerosValues=0;
int N,i;
float number;
printf("Enter the number of values: ");
scanf("%d",&N);
for(i=0;i<N;i++){
printf("Enter a real number %d: ",(i+1));
scanf("%f",&number);
if(number>0){
numberOfPositiveValues++;
}else if(number<0){
numberOfNegativesValues++;
}else{
numberOfZerosValues++;
}
}
printf("\nNumber of positive values: %d\n",numberOfPositiveValues);
printf("Number of negatives values: %d\n",numberOfNegativesValues);
printf("Number of zeros values: %d\n",numberOfZerosValues);
getchar();
getchar();
return 0;
}
Comments
Leave a comment