Home » C Basic I/O programs

C program to read marks and print percentage and division



In this C program, we are going to read marks in 3 subjects, we will find the total, percentage and print the division based on the percentage.
Submitted by Manju Tomar, on October 09, 2017

Given (or input from the user) marks in 3 subjects and we have to calculate parentage and print the division.

Formula to get percentage: Total obtained marks *100/Grand total (total of maximum marks)

Division

Based on the percentage, we will print the division, if percentage is:

  1. Greater than or equal to 60, division will be "First"
  2. Greater than or equal to 50, division will be "Second"
  3. Greater than or equal to 40, division will be "Third"
  4. Less than it (we will not check any condition, it will be written in else), the result will be fail


Consider the program:

#include<stdio.h>
int main()
{
	int science; 
	int math;
	int english;
	
	int total;
	float per;

	science = 50;
	math = 90;
	english = 40;
	//you can take input from user instead of these values

	//calculating total
	total= science + math + english;
	
	//calculating percentage
	per= (float) total*100/300;

	printf("Total Marks: %d\n",total);
	printf("Percentage is: %.2f\n",per);

	//checking division and printing
	if(per>=60)
	{
		printf("First division\n");
	}
	else if(per>=50)
	{
		printf("Second division");
	}
	else if(per>=40)
	{
		printf("Third division");
	}
	else
	{
		printf("Fail\n");
	}
	
	return 0;
}

Output

Total Marks: 180
Percentage is: 60.00
First division

This is a simple C program, if you are a beginner you will learn to calculate total, percentage and how to find division (example of multiple if else).

If liked or any issue with the program, feel free to leave your comment.






Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions





© https://www.includehelp.com (2015-2018), Some rights reserved.




Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.
Close