Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please check. I am trying to fix the two errors but I don\'t know what I\'m doin

ID: 3800806 • Letter: P

Question

Please check. I am trying to fix the two errors but I don't know what I'm doing wrong.

#include <stdio.h>
#include <stdlib.h>

int main() {
char choice; // choice of user
int percentArray[50];
int percentage;
int count=0;
char LetterGrade;

for (count=0; count<50; count++){ //for loop to read the grades till array size
printf("-------------------Enter percentage--------------- Add marks(a) Quit(q) ")

scanf choice

if(choice == 'a'){ //if user choice is a, then read the grade
printf "Enter grade:";

scanf percentage;
  
percentArray[count] = percentage; //add the grade to array
}

if(choice == 'q'){ //if the user choice is q, then exit the loop
break;
}

}

printf "Grades are: "

for (int i=0; i<count; i++){ //print grades
printf percentArray[i] " "
}
return 0;
}

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>
int main()
{
   char choice; // choice of user
   int percentArray[50];  
   int percentage;
   int count=0,i;
   //char LetterGrade;
   for(count=0; count<50; count++)
   { //for loop to read the grades till array size
       printf("-------------------Enter percentage--------------- Add marks(a) Quit(q) ");
       scanf("%c",&choice);
       if(choice == 'a')
       { //if user choice is a, then read the grade
       printf( "Enter grade:");
       scanf("%d", &percentage);
           percentArray[count] = percentage; //add the grade to array
       }
       if(choice == 'q')
       { //if the user choice is q, then exit the loop
           break;
       }
   }
   printf("Grades are: ");
   for(i=0; i<count; i++)
   { //print grades
       printf("%d ", percentArray[i]);
   }
   return 0;
}

now the program is error free