Answer to Question #264758 in C for Jack

Question #264758


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 .

1
Expert's answer
2021-11-12T00:55:01-0500
#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;
}

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