Answer to Question #206996 in C for tafadzwa

Question #206996

code a program to get an unknown number of test percentages from the user. accept percentage until the user enter a percentage of -99. this number -99 indicates the end of the data and must not be used as part of the calculations.


1
Expert's answer
2021-06-14T13:11:52-0400
#include<stdio.h>
#include<stdlib.h>


//The start point of the program
int main( void){
	int testPercentages[1000];
	int testPercentage=0;
	int i=0;
	int totalTestPercentages=0;
	while(testPercentage!=-99){
		printf("Enter test percentage [-99 to exit]: ");
		scanf("%d",&testPercentage);
		if(testPercentage!=-99 && testPercentage>=0 && testPercentage<=100){
			testPercentages[i]=testPercentage;
			i++;
			totalTestPercentages++;
		}
		
	}
	printf("\nAll test percentages:\n");
	for(i=0;i<totalTestPercentages;i++){
		printf("%d\n",testPercentages[i]);
	}


	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