Question

In: Computer Science

Write a C program that prints the Grade of each student in a class based on...

Write a C program that prints the Grade of each student in a class based on their mark. The program must also print the average mark of the class.

The program must prompt (ask) the user for the mark of a student (out of 100).

The program must then print the mark entered and the grade received based on the table below.

Grade

Range

A

85 to 100 inclusive

B

75 to 85 inclusive

C

60 to 70 inclusive

D

50 to 60 inclusive

F

Less than 50

For example “The student mark is 87 and their grade is A.”

This must be done repeatedly until a mark of -1 is entered.

The average mark of all of the class must then be shown.

For Example “The average mark of the class is 34.23.”

Note: To calculate the average, you must add up (total) all of the marks and then divide by the number of students (number of marks entered)

  • The choice of appropriate data types (variable type) is necessary
  • Appropriate Variable names must be used

Solutions

Expert Solution

Complete C Program with output is given below.

C Code :


#include <stdio.h>


int main()
{
int marks[100],i=0,sum=0,k=0;
float avg;
while(k==0)
{
printf("Enter mark (out of 100) : ");
scanf("%d",&marks[i]);
if(marks[i]==-1)
{
k++;
break;
}
if(marks[i]>85 && marks[i]<=100)
{
printf("The student mark is %d and his grade is A.\n",marks[i]);
}
else if(marks[i]>75 && marks[i]<=85)
{
printf("The student mark is %d and his grade is B.\n",marks[i]);
}
else if(marks[i]>60 && marks[i]<=75)
{
printf("The student mark is %d and his grade is C.\n",marks[i]);
}
else if(marks[i]>=50 && marks[i]<=60)
{
printf("The student mark is %d and his grade is D.\n",marks[i]);
}
else if(marks[i]<50)
{
printf("The student mark is %d and his grade is F.\n",marks[i]);
}
else
printf("Error!! Mark is not in range from 0 - 100.\n");
  
sum=sum+marks[i];
i++;
}
avg=(float)sum/i;
printf("The average mark of the class is %.2f.",avg);

return 0;
}

Output :

If you have any doubt regarding the solution then let me know in comment. If it helps, kindly give an upVote to this answer.


Related Solutions

Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this course (CSC100 online) based on three user inputs. This program should begin by printing the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prolog: a prolog is much more detailed, has required elements, and is intended for other programmers reading the cpp file. The title and description displayed by the...
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The...
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The program should allow creation an array of object instances to assign firstName, lastName and mark from input user and perform and assign grade based on mark’s criteria displayed below. MARKS INTERVAL 95 - 100 90 - <95 85 - <90 80 - <85 75 - <80 70 - <75 65 - <70 60 - <65 0 - <60 LETTER GRADE A+ A B+ B...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else statement logic​​​​​​​​​ b)​Write a Matlab program for sensor selection of temperature, pressure, flow sensor with if-else statement logic​​​​​​​​​ ​ 2.​Assume there are four letters from an information source with probabilities as A1 0.5 A2 0.3 A3 0.1 A4 0.1 Generate the tag and find the corresponding gaps and binary values for each stage and the sequence of the symbols which are coded are a1a3a2a4a1.​​​...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade and the program will determine if that grade is an A, B, C, D, or E. The student can only enter number 0-100. A = 90-100 B = 80-89 C = 70-79 D= 60-69 E = 59 or less Save the file as Lab3.4 and submit the file. Use https://repl.it/ THIS LANGUAGE IS PYTHON Thank you :)
5. Write a CH program that takes the marks of a student as input and prints...
5. Write a CH program that takes the marks of a student as input and prints the grade on screen according to the following criteria: CRITERIA LESS THAN 60 GREATER THAN 60 BUT LESS THAN 65 GREATER THAN 65 BUT LESS THAN 70 GREATER THAN 70 BUT LESS THAN 75 GREATER THAN 75 BUT LESS THAN 80 GREATER THAN 80 BUT LESS THAN 85 GREATER THAN 85 BUT LESS THAN 90 GREATER THAN 90 GRADE F D D+ с C+...
Write a for-each loop that prints all of the Student objects in an ArrayList<student> object called...
Write a for-each loop that prints all of the Student objects in an ArrayList<student> object called roster. Write this piece in Java. Write the correct code to execute.
Programming in C++ Write a program that prints the values in an array and the addresses...
Programming in C++ Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
Programming In C Write a program that prints the values in an array and the addresses...
Programming In C Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
In the C# programming language... Write a program to perform student record manage for class IST311....
In the C# programming language... Write a program to perform student record manage for class IST311. Create student record class (Student.cs) and it should get the student information from the user and set up student record class. The program will perform recording student’s grade information and compute final grade, and then print out the student’s class information. Student class definitions: It should contain attributes as following: first name, last name, 5 labs grade, 3 grade, final grade. Its member functions...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT