How to find total and percentage of marks using function?
CODE
How to find total and percentage
of marks using function?
//Write a function :
dototal() with 3 sunject marks as arguments and return total to main(). Then
pass total from main() to function: doper(),to calculate percentage and return per
to main and show on screen.
int
main()
{
    float s1,s2,s3,total,per;
    printf("\n enter marks of 3 subjects(out
of 100 each):");
   
scanf("%f%f%f",&s1,&s2,&s3);
    float dototal(float s1,float s2,float s3);
    total=dototal(s1,s2,s3);
    float doper(float total);
    per=doper(total);
    printf("\n total=%f",total);
    printf("\n percentage=%f",per);
}
float
dototal(float s1,float s2,float s3)
{
    float total=s1+s2+s3;
    return total;
}
float
doper(float total)
{
    float per=total*100/300;
    return per;25194
}
Output:
enter marks of 3
subjects(out of 100 each):
87
98
100
 total=285.000000
 percentage=95.000000
How to find total and percentage of marks using function?
 Reviewed by Unknown
        on 
        
December 31, 2018
 
        Rating:
 
        Reviewed by Unknown
        on 
        
December 31, 2018
 
        Rating: 
No comments:
If you have any doubt or query ,comment below: