| 0 | kirasiris | Categories: Tags: , , , ,

c++ average

Easy beatsy?. Is that how you say it?…yeah, English is not my native language but I think this could be useful for you or your class; get to know about your average grade. I created this long ago and its not complex at all, just some basic strings, floats, doubles and you’re done!.

This program will let you know how to calculate your average grade. Right now I just declared 4 grades, if you need more you can just added them into the program; I’m sure you will get to know how it works pretty easily without any help.

  Program: Lab 1 C++


  This program calculates the average grade

  first grade
  second grade
  third grade
  fourth grade

  average grade is displayed on screen/console.



using namespace std;

int main(){

    // Declare variables
    double first_grade, second_grade, third_grade, fourth_grade;
    float average_grade;

    // Get the first grade
    cout << "Please enter first grade "; cin >> first_grade;

    // Get the second grade
    cout << "Please enter second grade "; cin >> second_grade;

    // Get the third grade
    cout << "Please enter third grade "; cin >> third_grade;

    // Get the fourth grade
    cout << "Please enter fourth grade "; cin >> fourth_grade;

    // Calculates the average grade
    average_grade = (first_grade + second_grade + third_grade + fourth_grade)/4;

    // Display the average grade
    cout << "The average grade is: " << average_grade << endl;

    // Pause it.

    return 0;


Please share it with your friends and remember to always practice. Normally when I’m not coding personal complex projects, I code just for code which is something that some of you guys might think as useless but you need to remember the only way to get better is by practicing even if your programs is not complex.

Do you by any chance would like to create an userId generator system? If you do, I recommend you to check my previous article made in Java which will show you exactly how its made!:

Create a userId Generator using Java

I have a whole bunch of mini-programs like this one in my computer…hidden somewhere, I will try to find them all and will post them on here, stay tuned!. Besides it will refresh my mind of how C++ works, I mean I already know but I never really paid attention since I’m more into web browser programming languages but I would not mind working on it just to create simple programs such as the one I’m talking about on this post.

Leave a Reply

Back to Top