Stack Exchange
why am i getting a run time error when i debug my nested if statement program?
#include <iostream>
`#include <string>
using namespace std;
int main()
{
int test1, test2, test3;
int testAverage;
testAverage = (test1 + test2 + test3)/3;
cout << "Please enter your three test scores" << endl;
cin >> test1;
cin >> test2;
cin >> test3;
cout << "Your total test average is " << testAverage << endl;//my total     average displays an insanly high number here as well im unsure why
if (testAverage >= 90)

    cout << "Your Grade Is an A average" << endl;

else
{
    if (testAverage < 90)
    {
        cout << "Your test average is B" << endl;
    }
    else if (testAverage < 80)
    {
        cout << "Your test average is C" << endl;
    }
    else
    {
        if (testAverage < 70)
        {
            cout << "Your test average is D" << endl;
        }
    }
}
        return 0;
    }

//im not sure if it is the way i nested the if statements with the brackets for i am fairly new to it, or if it is something else wrong that i am doing. Can someone can let me know why the run time error is occurring and why the math is coming out crazy, and even help me clean up my code. The question for the homework is to display a grade for the average of three test scores in a nested if statement format. P.S i believe the problem has to do with the brackets but i am unsure.

I'm not sure why you are using "<<" syntax. 
1) What program are you writing this in?
2) Does your input work correctly? Try printing your variables test1, test2 and test3 right after receiving input to see if they match. 
Hopefully, this helps!
