C PROGRAMMING, NOT C++ Write a C program to calculate letter grade scores for st
ID: 3679453 • Letter: C
Question
C PROGRAMMING, NOT C++
Write a C program to calculate letter grade scores for students in a class; the letter grade is based on average of three tests, each test is worth 100 points:
The program should ask for the student information and score for each of the three test.
Student Information:
Student’s first name, student’s last name and then scores for each test (scores must be read using a function).
After score for the 3 tests has been entered, the following output will be displayed on the screen and also in an output file:
Student Name: First Name, Last Name
Average Score: Average of the 3 tests, up to 2 decimal points.
Letter Grade: letter grade is evaluated according to the following table:
90 or higher A
80 – 89.99 B
70 – 79.99 C
60 – 69.99 D
Less than 60 F
The program should then prompt user “Calculate another student grade: (press Y for Yes, press N for No)”:
If the user input is “Y” or “y”, program should prompt for student information (see above).
If the user input in “N” or “n”, program should end.
Test score reading function
Prompt user to enter score for a test – the function should validate that the score entered is correct:
Must be positive number
Cannot be more than the maximum score for the test i.e. more than 100.
If an invalid score has been entered, display a message “Invalid score, the valid range is 0 – 100”; ask user to re-enter the score. This should repeat until the user enters a valid score.
Submission
Submit the “C” program file.
Submit a screenshot of your program output. Make sure to use data to test all conditions listed above. The screenshot must include entry of invalid data and corresponding error message
Output file
Explanation / Answer
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
int rollno;
char fname[20];
char lname[20];
int m1,m2,m3;
float average;
float percent
};
struct student s[20],t;
int i,j,n;
clrscr();
printf(" enter the number of students");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf(" enter the roll no ");
scanf("%d",&s[i].rollno);
printf(" enter the name ");
scanf("%s",s[i].fname);
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
int rollno;
char name[20];
int m1,m2,m3;
float percent;
};
struct student s[20],t;
int i,j,n;
clrscr();
printf(" enter the limit");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf(" enter the roll no ");
scanf("%d",&s[i].rollno);
printf(" enter the firstname ");
scanf("%s",s[i].fname);
printf(" enter the lastname ");
scanf("%s",s[i].lname);
printf(" enter the mark=");
scanf("%d",&s[i].m1);
printf(" enter the mark=");
scanf("%d",&s[i].m2);
printf(" enter the mark=");
scanf("%d",&s[i].m3);
s[i].average=(s[i].m1+s[i].m2+s[i].m3)/3;
gradecalc(s[i].average);
void gradecalc(s[10])
{
if(s[i].average>=90
{ printf(“A”);
elseif((s[i].average>=80 && s[i].average<=89.99)
{ printf(“B”);
elseif(s[i].average>=70 && s[i].average<=79.99)
{ printf(“C”);
elseif(s[i].average>=60 && s[i].average<=69.99)
{ printf(“D”);
else
printf(“F”)
}
for(i=0;i<n;i++)
{
printf(" rollno=%d",s[i].rollno);
printf(" name=%s",s[i].name);
printf(" mark1=%d",s[i].m1);
printf(" mark2=%d",s[i].m2);
printf(" mark3=%d",s[i].m3);
printf(" percent=%f",s[i].average);
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.