I've been programming for like, a week or something and I can't figure out how to make a program restart in C ++ once you've reached the end. Can someone help me?
I've written this begginer letter grade program that tells you based on your score, what letter grade you got. But as I said, once you reach the end and you're given the answer, the program ends, like expected, but I want it to restart and let me put in another number. Thanks!
#include <iostream>
using namespace std;
int main()
{
long int grade;
string x = " ";
cout << "Please, enter your grade. (0-100)" << endl;
cin >> grade;
int P =grade == 100;
int A =grade >= 90;
int B =grade >= 80;
int C =grade >= 70;
int D =grade >= 60;
int F =grade >= 0;
if(P){cout << "You have a perfect score." << endl << endl;}else{
if(A){cout <<"You have an A." << endl<< endl; }else{
if(B){cout <<"You have a B." << endl << endl;}else{
if(C){cout <<"You have a C." << endl;}else{
if(D){cout <<"You have a D." << endl<< endl;}else{
if(F){cout <<"You have an F."<< endl<< endl;}else{
cout << "Invalid input.";
}
}
}
}
}
}
cout << "Enter x to finish the program" << endl << endl;
cin >> x;
}