How to calculate percentage in C programming?

Table of Contents

INPUT

// Percentage of Marks
#include<stdio.h>
int main()
{
    float t_marks,o_marks,percentage;
    printf("Enter Following Credentials\n");
    printf("Total Marks: ");
    scanf("%f",&t_marks);
    printf("Obtained Marks: ");
    scanf("%f",&o_marks);
    percentage=o_marks*100/t_marks;
    printf("Percentage is %f",percentage);

}

OUTPUT

Enter Following Credentials
Total Marks: 400
Obtained Marks: 354
Percentage is 88.500000[1] + Done  

Leave a Comment

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

Scroll to Top