I need some help with my code I keep getting errors that say
I need some help with my code. I keep getting errors that say
uninitialized local variable \'A\' used
uninitialized local variable \'B\' used
uninitialized local variable \'C\' used
uninitialized local variable \'D\' used
uninitialized local variable \'F\' used
here is the code, in c++
#include <iostream>
#include <string>
using namespace std;
int main()
{
char grade;
char A, B, C, D, F;
cout << \"What Letter grade did you earn in Programming I ? \ \";
cin >> grade;
if (grade == A)
{
cout << \" an A - excellent work! \ \";
}
else if (grade == B)
{
cout << \"you got a B good job \ \";
}
else if (grade == C)
{
cout << \"earning a C is satisfactory \ \";
}
else if (grade == D)
{
cout << \"while D is passing, there is a problem \ \";
}
else if (grade == F)
{
cout << \"you failed - try harder next time \ \";
}
else
{
cout << \" You did not enter an A,B,C,D, or F \ \";
}
return 0 ;
}
Solution
#include <iostream>
#include <string>
using namespace std;
int main()
{
char grade;
//char A, B, C, D, F;
cout << \"What Letter grade did you earn in Programming I? \";
cin >> grade;
if (grade == \'A\')
{
cout << \"an A - excellent work! \ \";
}
else if (grade == \'B\')
{
cout << \"You got a B good job \ \";
}
else if (grade == \'C\')
{
cout << \"earning a C is satisfactory \ \";
}
else if (grade == \'D\')
{
cout << \"while D is passing, there is a problem \ \";
}
else if (grade == \'F\')
{
cout << \"You failed - try harder next time \ \";
}
else
{
cout << \"You did not enter an A,B,C,D, or F \ \";
}
return 0 ;
}

