Objectives: Practice function definition Write a function to map a score to a gr
ID: 3664330 • Letter: O
Question
Objectives: Practice function definition Write a function to map a score to a grade based on the following table: grade Score A 800 B 700 C 600 D 500 F 500 The function should be named point to grade and be able to accept an integer, representing a score, as argument. It should return a character that is the grade corresponding to the input score Function specifications: Function name point to grade nput parameter o an integer representing a score Return value o a character representing a grade o For example, if input parameter is 750, then the return value should be B Testing: Develop at least 2 test cases, calculate the correct results by hand, and then confirm that your program gives the same results To test the correctness of your function, you can make function calls, one for each of your test cases. For example, print (point to grade (750) should display B on screen. When you are ready to submit, remove all such function calls from your script file. You do not need to submit your test cases. Code specifications: Your submitted .py file should contain ONLY your function definition for point to grade DO NOT include your testing codes. The instructor will use his test cases for testing your function.Explanation / Answer
#include<stdio.h>
#include<conio.h>
int main()
{
char point_to_grade(int);
int score;
char grade;
printf(" enter score");
scanf("%d",&score);
grade=point_to_grade(score);
printf(" The grade is %c",grade);
getch();
return 0;
}
char point_to_grade(int s)
{
char g;
if(s >=800)
g='A';
else if(s>=700)
g='B';
else if(s>=600)
g='C';
else if(s>=500)
g='D' ;
else if(s <500)
g='F';
return g;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.