Today we will learn how to write a C language program to work as marks percentage calculator. If we wish to calculate the percentage obtained by a student, we will use this C language program.
This program uses simple C language statements. The detail of the statements used in this C language program is as follows:
- Writing basic C language program template that is basic structure of C program.
- Using variable declarations
- Use of printf() for output / displaying messages to user of program.
- using scanf() function as input statement.
- We will use simple assignment statement to calculate marks percentage.
- This is the whole story about marks percentage calculating program in C language.
The Source Code for Marks Percentage Calculator
/* Marks Percentage Calculator */
#include<stdio.h>
int main()
{
float obtainedMarks, totalMarks, percentage;
printf(“Enter the Obtained Marks of a Student:”);
scanf(“%f”, &obtainedMarks);
printf(“Enter the Total Marks:”);
scanf(“%f”, &totalMarks);
percentage = obtainedMarks / totalMarks * 100.0;
printf(“Required Marks Percentage = %.2f %%”,percentage);
return 0;
}