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.
#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;
}
Comments
Leave a comment