Pages

Thursday, 8 February 2018

Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main( ) and print the results in main( ).


Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main( ) and print the results in main( ).
#include <stdio.h>
void calc(int i, int j, int k, int full, float *ave, float *perce)
{
 *ave = (i + j + k) / 3.0;
 *perce = (*ave / full)*100.0;
}

int  main( )
{
 int a, b, c, full;
 float av, perc;
 printf("Enter the marks received by the student in 3 subjects and the total possible marks for 1 paper:");
 scanf("%d,%d,%d,%d", &a, &b, &c, &full);
 calc(a, b, c, full, &av, &perc);
 printf("\nThe average marks is %f.\nThe percentage is %f\n", av, perc);
 return 0;
}