Question: write a description for every line in a program the description must include the line number and the value of the variables on the line
write a description for every line in a program the description must include the line number and the value of the variables on the line you only describe the lines which are executed if a line is excuted more than once, you describe it more than once
#define _CRT_SECURE_NO_WARNINGS
#include
#define Max_marks 10
#define Max_STUDENtS 2
struct StudentRec
{
int studentNumber;
int numMarks;
double marks[Max_marks]
};
int main(void)
{
struct StudentRec studentInfo[Max_STUDENtS] =
{
{7721, 1, {92,6}}, {7834,2,{66.7,68.4}}
};
double gradeRanges[] = { 50.0, 55.0,60.0,75.0,80.0,85.0,90.0 };
char letters[] = { 'F','D','C','B','A' };
int i, j, numStudents = 2, numRanges = 8, plus, found;
char letterGrade;
double sum, avg;
for (i = 0; i < numStudents; i++)
{
sum = 0.0;
for (j = 0; j < studentInfo[i].numMarks; j++)
{
sum += studentInfo[i].marks[j];
}
avg = sum / studentInfo[i].numMarks;
found = 0;
for (j = numRanges - 1; j >= 0 && !found; j--)
{
if (avg >= gradeRanges[j])
{
letterGrade = letters[(j / 2 + 1)];
plus = j % 2;
found = 1;
}
}
}
if (!found)
{
letterGrade = letters[0];
}
printf("%d %c %c ", studentInfo[i].studentNumber, letterGrade, (plus ? '+' : ' '));
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
