Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c for result

/**
 * 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
", total);
    printf("Average marks = %.2f
", average);
    printf("Percentage = %.2f", percentage);

    return 0;
}
Source by codeforwin.org #
 
PREVIOUS NEXT
Tagged: #result
ADD COMMENT
Topic
Name
8+2 =