C Program to Calculate Total, Average, and Percentage of Five Subjects

C Program to Calculate Total, Average, and Percentage of Five Subjects

C program to calculate total marks and percentage of five subjects; Through this tutorial, we will learn how to calculate total marks, average and percent of five subjects in c.

Algorithm to Calculate Total, Average, and Percentage of Five Subjects Marks

Use the following algorithm to calculate write a program to calculate total marks and percentage of three subjects; as follows:

  1. Read five subject marks and store them into variables.
  2. Calculate sum of all subjects and store in total = eng + phy + chem + math + comp.
  3. Divide sum of all subjects by total number of subject to find average i.e. average = total / 5.
  4. Calculate percentage using percentage = (total / 500) * 100.
  5. Finally, print resultant values totalaverage and percentage.

C Program to Calculate Total, Average, and Percentage of Five Subjects

/**
 * C program to calculate total, average and percentage of five subjects
 */

#include <stdio.h>

int main()
{
    float eng, phy, chem, math, comp; 
    float total, average, percentage;

    /* Input marks of all five subjects */
    printf("Enter marks of five subjects: :- ");
    scanf("%f%f%f%f%f", &eng, &phy, &chem, &math, &comp);

    /* Calculate total, average and percentage */
    total = eng + phy + chem + math + comp;
    average = total / 5.0;
    percentage = (total / 500.0) * 100;

    /* Print all results */
    printf("Total marks = %.2f\n", total);
    printf("Average marks = %.2f\n", average);
    printf("Percentage = %.2f", percentage);

    return 0;
}

The Output of the above c program; as follow:

Enter marks of five subjects: :- 56 96 45 78 88
Total marks = 363.00
Average marks = 72.60
Percentage = 72.60

Recommended C Programs

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

One reply to C Program to Calculate Total, Average, and Percentage of Five Subjects

  1. C++ program

Leave a Reply

Your email address will not be published. Required fields are marked *