Answer to Question #209556 in C for tafadzwa

Question #209556

Declare an array to store up to 10 integer percentage values.

Ask the user to input 10 percentages (range 0 – 100). Verify that the input is valid, before storing it in the array. Note that only valid (0 – 100) percentages may be stored. if the user enters an invalid percentage: display an error message and do not store or process the invalid value. After the error message, prompt for the next input.once all 10 valid percentages are entered, calculate the average percentage and display it.  

Calculate and display the highest and lowest percentage obtained.

Then display all percentages that are equal to or more than the average.

  

Lastly, display all 10 values entered by the user together with their letter grade values, one percentage and letter grade per line.

  


1
Expert's answer
2021-06-23T02:56:42-0400
#include<stdio.h>




int main(){
	int percentage[10];
	int valid[10];
	int dram;
	for(int i = 0; i< 10; i++){
		printf("Enter integer: %d\t", (i+1));
		scanf("%d", &dram);
		if(dram >0 && dram<100){
			percentage[i] = dram;
		}
		else{
			printf("Invalid Integer");
		}
			
		
}
for(int i=0; i<10; i++){
	 printf("%d\n",percentage[i]);
}
double sum = 0.0;
for(int i =0; i<10; i++){
   
	sum += percentage[i];
}
  int lowest = percentage[0], highest = percentage[0];
  
double average = sum /10;
printf("\nThe average is\t%f\n", average);
 int min = percentage[0], max = percentage[0];


for(int i=0; i<10; i++){
	 if (percentage[i] < min)
        {
            min = percentage[i];
        }
        
        if (percentage[i] > max)
        {
            max = percentage[i];
        }
}
printf("The maximum is:\t%d\n",max);
printf("The minimum is:\t%d\n",min);
for(int i =0; i<10; i++){
	if(percentage[i]>= average){
		printf("%d\t", percentage[i]);
	}
}


}

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