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

write a function called letter_grade that has a type int input parameter called

ID: 3568109 • Letter: W

Question

write a function called letter_grade that has a type int input parameter called points and returns through an output parameter gradep the appropriate letter grade using a straight scale (90-100 is an A, 80-89 is a B, and so on). Return through a second output parameter (just_missedp) an indication of whether the student just missed the next higher grade (true for 89, 79, 69 and so on).

I'm not exactly what type of C programming I am doing. We use codeblocker and use statements such as printf and scanf.

Explanation / Answer

#include <stdio.h>
#include <unistd.h>
#include<string.h>
typedef int bool;
#define true 1
#define false 0

void letter_grade(int points, char *gradep, bool *just_missedp)
{
   if(points>=90 && points<=100)
       *gradep = 'A';
  
   else if(points>=80 && points<=89)
       *gradep = 'B';
  
   else if(points>=70 && points<=79)
       *gradep = 'C';
      
   else if(points>=60 && points<=69)
       *gradep = 'D';
      
   else if(points>=50 && points<=59)
       *gradep = 'E';
      
   else if(points>=40 && points<=49)
       *gradep = 'F';
      
   else if(points>=30 && points<=39)
       *gradep = 'G';
      
   else if(points>=20 && points<=29)
       *gradep = 'H';
      
   else if(points>=10 && points<=19)
       *gradep = 'I';
      
   else
       *gradep = 'J';
      
   if((points + 1) != 100 && (points + 1)%10 == 0)
       *just_missedp = true;
   else
       *just_missedp = false;
}
int main(int argc, char * argv[]) {
  
int points;
char gradep;
bool just_missedp;
printf("Input points: ");
scanf("%d", &points);
  
letter_grade(points, &gradep, &just_missedp);
  
printf(" So, Grade is: %c", gradep);
  
if(just_missedp)
   printf(" Just missed next higher grade ");
  
return 0;
}

-------------------

OUTPUT