Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Write a C Program to find the percentage of marks ?

Here is a C programme that computes the percentage of exam marks earned by a student:

#include <stdio.h>

int main() {
    int marks_obtained, total_marks;
    float percentage;

    // Get the marks obtained and total marks from the user
    printf("Enter the marks obtained: ");
    scanf("%d", &marks_obtained);

    printf("Enter the total marks: ");
    scanf("%d", &total_marks);

    // Calculate the percentage
    percentage = ((float)marks_obtained / total_marks) * 100;

    // Display the percentage
    printf("Percentage = %.2f%%\n", percentage);

    return 0;


Enter the marks obtained: 90
Enter the total marks: 250
Percentage = 36.00%

In this program, we first declare three variables: marks_obtained, total_marks, and percentage. We then use printf() and scanf() to get the values of marks_obtained and total_marks from the user.

We then calculate the percentage by dividing marks_obtained by total_marks, multiplying the result by 100, and storing the result in percentage.

Finally, we use printf() to display the percentage with two decimal places and a percent sign. Note that we use the %.2f format specifier to display the percentage with two decimal places.