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.
#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.
Related courses
Related learning
Recommended automatically from shared technologies, topics, intent, and difficulty.
Related Guides
Related Tutorials
Related Glossary
Related Cheatsheets
Related Projects
Related Interview Questions
Related reading
Hand-picked companion pages that deepen this topic.
Your next steps
