C Programming
Computer Programming

C Program using function to calculate sum of 5 subjects and find percentage



Write a Program in C using function to calculate sum of 5 subjects and find percentage

\* C Program using function to calculate sum of 5 subjects and find percentage *\

# include < stdio.h >
# include < conio.h >
int   sum(int, int, int, int, int) ;
float   percentage(int) ;

int   main( )
{

int s1, s2, s3, s4, s5, s ;
float per ;
printf(" Enter the mark of first Subject : ") ;
scanf("%d", &s1 ) ;
printf(" Enter the mark of second Subject : ") ;
scanf("%d", &s2 ) ;
printf(" Enter the mark of third Subject : ") ;
scanf("%d", &s3 ) ;
printf(" Enter the mark of fourth Subject : ") ;
scanf("%d", &s4 ) ;
printf(" Enter the mark of fifth Subject : ") ;
scanf("%d", &s5 ) ;

s = sum( s1, s2, s3, s4, s5 ) ;
printf("\n Sum of five subject marks are : %d ", s ) ;
per = percentage(s) ;
printf("\n Percentage of five subjects are : %f ", per ) ;
return (0) ;

}

int   sum( int s1,int s2, int s3, int s4, int s5 )
{

float s ;
s = ( s1 + s2 +s3 + s4 + s5 ) ;
return s;

}

float   percentage( int s )
{

float s ;
per = s/5 ;
return per;

}

Output of Program :

Output of C Program using function to calculate sum of 5 subjects and find percentage