Question
ZYBOOKS HELP. Please advise why I am getting this error in my code and help me fix the code: Program generated too much output. Output
ZYBOOKS HELP.
Please advise why I am getting this error in my code and help me fix the code: Program generated too much output. Output restricted to 50000 characters. Check program for any unterminated loops generating output.
#include
int main()
{
int jerseyNumber[5];
int rating[5];
int num,rate;
int flag=0;
char choice='o';
for(int i=0;i<5;i++){
printf(" Enter player %d's jersey number: ",(i+1));
scanf("%d",&num);
printf("Enter player %d's rating: ",(i+1));
scanf("%d",&rate);
while((num<0 || num>99) || (rate<1 || rate>9)){
printf("Wrong value entered!! Please enter jerseyNumber between 0-99 and rating between 1-9.");
if(num<0 || num>99){
printf(" Enter player %d's jersey number: ",(i+1));
scanf("%d",&num);
}
if(rating[i]<1 || rating[i]>9){
printf("Enter player %d's rating: ",(i+1));
scanf("%d",&rate);
}
}
jerseyNumber[i]=num;
rating[i]=rate;
}
printf(" ROSTER");
for(int i=0; i<5;i++){
printf(" Player %d -- Jersey number: %d, Rating: %d",(i+1),jerseyNumber[i],rating[i]);
}
int countRoster=5;
while(choice!='q'){
printf(" MENU u - Update player rating a - Output players above a rating r - Replace Player o - Output roster q - Quit Choose an option : ");
getchar();
choice=getchar();
if(choice=='a'){
int ratings;
printf("Enter a rating: ");
scanf("%d",&ratings);
int fl=0,index=1;
printf("Above %d",ratings);
for(int i=0;i if(ratings printf(" Player %d -- Jersey number: %d , Rating: %d ",index,jerseyNumber[i],rating[i]); fl=1; index++; } } if(fl==0){ printf("No ratings exist"); } } else if(choice=='u'){ int jno; printf("Enter a jersey number: "); scanf("%d",&jno); int fl=0,newrating; printf("Enter a new rating for player: "); scanf("%d",&newrating); for(int i=0;i if(jno==jerseyNumber[i]){ while((newrating<1 || newrating>9)) { printf("Please enter rating between 1 to 9!!Enter a new rating for player: "); scanf("%d",&newrating); } rating[i]=newrating; fl=1; break; } } if(fl==0){ printf("Invalid jersey number"); } else{ printf("Updated rating."); } } else if(choice=='o'){ printf(" ROSTER"); for(int i=0; i<5;i++){ printf(" Player %d -- Jersey number: %d, Rating: %d",(i+1),jerseyNumber[i],rating[i]); } } else if(choice=='r'){ int jno; printf("Enter a jersey number: "); scanf("%d",&jno); int fl=0,newjno,newrating; for(int i=0;i if(jno==jerseyNumber[i]){ printf("Enter a new jersey number: "); scanf("%d",&newjno); printf("Enter a rating for the new player: "); scanf("%d",&newrating); while((newjno<0 || newjno>99) || (newrating<1 || newrating>9)){ if(newjno<0 || newjno>99){ printf("Jersey number should be between 0 to 99.Enter a new jersey number: "); scanf("%d",&newjno); } if(newrating<1 || newrating>9){ printf("Rating should be between 1 to 9.Enter a rating for the newplayer: "); scanf("%d",&newrating); } } jerseyNumber[i]=newjno; rating[i]=newrating; fl=1; break; } } if(fl==0){ printf("Invalid jersey number"); } else{ printf("Updated player."); } } else if(choice=='q' ){ printf("Quiting program."); } else{ printf("Wrong choice entered."); } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started