BeginnersBook.in

Programming For Geeks

  • Home
  • All Tutorials
    • Learn C
    • Learn Python
  • Programs
    • Java Programs
    • C++ Programs
    • C Programs
  • Algorithms
    • Sorting
  • MCQ’s
    • MySQL
    • Operating System
  • WordPress
    • Genesis Pro Themes
    • Blogs
  • Tools
    • Direct Download Link Generator
    • HTML Compiler
  • How to
    • Web Examples
  • Write For Us

C++ Program to Calculate Grade of Student

May 4, 2018 By Mr. Robot

In this example, you will learn to calculate grade of a student. The user will ask to enter marks obtained in 5 subjects and calculate obtained grade of that student using if…else statement.

Example: Program to Calculate Grade of Student

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;
int main()
{
    int mark[5], i;
    float sum=0,avg;
    cout<<"Enter marks obtained in 5 subjects :" << endl;
    for(i = 0; i < 5; i++)
    {
        cin >> mark[i];
        sum = sum + mark[i];
    }
    avg = sum / 5;
    cout << "Your Grade is ";
    if(avg > 80)
    {
        cout << "A";
    }
    else if(avg > 60 && avg <= 80)
    {
        cout << "B";
    }
    else if(avg > 40 && avg <= 60)
    {
        cout << "C";
    }
    else
    {
        cout << "D";
    }
    return 0;
}
When you run the program, the output will be following:
1
2
3
4
5
6
7
Enter marks obtained in 5 subjects :
85
38
67
82
50
Your Grade is B

Filed Under: C++ Examples

Related Posts

  • C++ Program to Calculate Area of Circle by Calling Function
  • C++ Program to Check Whether a Matrix is Invertible
  • C++ Program to Find Inverse of a Matrix

Recent Posts

  • Download Grand Theft Auto: Vice City Audio File | Highly Compressed
  • Grand Theft Auto: Vice City Game Download For PC | Full Setup
  • SQL SHOW DATABASES Statement
  • Direct view storage Tube (DVST) in Computer Graphics
  • CRT Color Monitor in Computer Graphics

C++ Programs

  • More 300+ Examples
  • “Hello World” Program
  • Add Two Numbers
  • Area of Circle
  • Even or Odd Number
  • Find Factorial Number
  • Simple Calculator Program
  • Swap Two Numbers
  • Check Vowel and Consonant
  • Reverse a Number
  • Fibonacci Series
  • Leap Year
  • Toggle Characters
  • Check Super Digit
  • Check Anagram Strings
  • Spy Numbers
  • Check Automorphic Number
  • Check Neon Number
  • Check Pandigital Number
  • Strong Number
  • Inverse of Matrix

More C++ Examples…

  • Star(*) Pattern Programs
  • Wave Pattern Programs
  • Sorting Algorithms

Tutorials

  • C Tutorial

Copyright © 2019 - BeginnersBook.in - All Right Reserved || Sitemap