Skip to main content

Step-by-step tutorial

C++ (Cpp) Tutorial: Build a Student Grade Calculator

Read marks, decide pass or fail, and print a clear result with cout. Each step teaches one C++ idea you can reuse.

C++beginner4 min readProgramming tutorials

Learning overview

Estimated time
4 minutes
Difficulty
Beginner
Prerequisites
No prior experience required
Learning outcome
Explain cpp using a clear mental model · Apply cpp in practical C++ work
Last updated
July 18, 2026

What you will build and learn

You will build a grade calculator that stores a score, decides pass or fail, and prints a clear result with cout. Keep the decision separate from printing so each part stays easy to change.

  • Include iostream
  • Declare an int score
  • Use if/else for the pass decision
  • Print with cout and endl

Step 1: Create the program skeleton

Every beginner C++ program needs includes and a main function. main is where execution begins when you press Run.

grade.cpp
#include <iostream>
using namespace std;

int main() {
  int score = 72;
  if (score >= 40) {
    cout << "Pass" << endl;
  } else {
    cout << "Try again" << endl;
  }
  return 0;
}

Output

Pass

Project extensions

Add a second condition for distinction, or read the score with cin. Keep changes small and re-run after each edit.

  • Print Distinction when score >= 75
  • Read score with cin
  • Add a second subject average

Frequently asked questions

Do I need an IDE for this tutorial?

No. A simple editor and g++ are enough. Avora Learn also lets you practice visually.

Why return 0?

Returning 0 from main traditionally signals successful program completion.

Topic graph

A taxonomy-generated path through this subject.

  1. C++
  2. Programming tutorials
  3. cpp
  4. tutorial
  5. beginners
  6. cout
  7. What Is Cpp in Programming?
  8. Learn C++ (Cpp): From First Program to Object-Oriented Projects
  9. C Tutorial: Build a Student Grade Calculator

Recommended automatically from shared technologies, topics, intent, and difficulty.

Hand-picked companion pages that deepen this topic.

Your next steps

Continue learning

  1. 1glossaryWhat Is Cpp in Programming?
  2. 2guidesLearn C++ (Cpp): From First Program to Object-Oriented Projects
  3. 3guidesC Tutorial: Build a Student Grade Calculator
  4. 4guidesJava Tutorial: Build a Student Grade Calculator