C Program to Calculate Sum and Percentage of Marks

C, being a powerful and widely used programming language, allows developers to create efficient programs. In this tutorial, we’ll create a program that accepts marks for five subjects and calculates both the sum and the percentage marks obtained by a student.

C Program to Calculate Sum and Percentage of Marks

Problem Statement

WAP that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student

Understanding the Solution

Our C program will take inputs for marks obtained in five subjects from the user. It will then calculate the total marks by adding up these subject marks and compute the percentage by dividing the total marks by the total possible marks (assuming each subject has a maximum of 100 marks).

Here’s the step-by-step guide to creating this program:

C Program For Sum and Average

Output

C Program For Sum and Average

Explanation of C Program

  1. We start by declaring the necessary variables: an integer array of marks to store marks for each subject, an integer totalMarks to calculate the sum and a float percentage to store the percentage.
  2. Using a loop, the program prompts the user to input marks for each of the five subjects. These marks are stored in the marks array, and the totalMarks variable is incremented with each input.
  3. The total marks are then divided by the total possible marks (5 subjects, each with a maximum of 100 marks) to calculate the percentage.
  4. Finally, the program displays the total marks obtained and the percentage of marks on the console.

This simple C program efficiently computes the total marks obtained and the percentage of marks based on the input provided by the user. It showcases the capability of C to perform calculations and display results effectively. You can further explore and modify this code to suit various requirements and expand its functionalities.

See Also

1 thought on “C Program to Calculate Sum and Percentage of Marks”

Leave a Comment