I have a hw problem that has me baffled. Im sure It is not a big deal, i just am not that familiar with c++ yet.

I am tasked with assigning a char value to rate an employee
if I enter certain char's i should display a specified string.
and if the display is invalid I am to display that it was and to try again.
seems simple but It is beating me up.
First when I enter the char with cin>> the loop continously runs until i close the console.
second I am not even sure it is executing the strings if i enter a specified char.
Please help me.

#include <cstdlib>
#include <iostream>
using namespace std;
void GetRating(int x);// function prototype
int value;
int x=0;
int main ()

for (x=0;x==0;)
{cout<< "Enter employee rating"<<endl;
cout<< "use E, G, A or P: "<<endl;
  return EXIT_SUCCESS;

void GetRating (int x)

if (x=='e')
cout<<  " the employees rating was excellant"<<endl;
else if (x == 'g')
cout<<  " the employees rating was good"<<endl;
else if (x=='a')
cout<<  " the employees rating was average"<<endl;
else if (x=='p')
cout<<  " the employees rating was poor"<<endl;
cout<< "Rating invalid  Please try again:"<<endl;


I have tried do/while loops, i have tried calling the loop from the void function, I am trying but stumped.

You set the value of x to zero at the start of your loop, and your loop will end when x does not equal zero. Given that you don't change the value of x, when do you expect the loop to stop? (Never)

Have you mixed up the variable value and the variable x? They're two different variables.

thank you for the prompt reply, I had started trying multple things when I was getting frustrated, including changing my cin to value instead of x, i overlooked changing the the other instances to follow.
I will clean up rework the code again and try something different with the exit parameter foth the loop x to get the loop to stop.
I was able to stop before with an invalid entry it would exit the program instead of looping back into the void function to until a valid value for x was enterd, that is where i starting trying to find a way to hold it in the loop until x was equal to one of the characters passed in the loop, i wasnt sure how to do that with multiple values available so i though if i could set x to a know value and look for it to change from that value to exit the loop it would work.
is there a simpler way to do this?

I am writing now with 2 loops, i think that may have been my initial problem.

You could replace your for loop with this. Note that your getRating function would then have to do something sensible with the input value 'x' (I suggest it simply does nothing).

char input = 'a'; // Some starting value
while (input != 'x')
cout<< "Enter employee rating"<<endl;
cout<< "use E, G, A or P: "<<endl;
cout<< "or 'x' to exit"<<endl;
cin >> input;

You're asking for input of a character but your variable is an integer, which can only be numerical. The problem your seeing is common to mis-matched variable types.

A for loop is also the incorrect type of loop for this particular function. The loop outlined above would serve your purpose better.

Also note that you're asking for upper-case inputs ("E, A, G, P"), but your function is actually looking for lower case inputs ("e, a, g, p"). If you entered "E" it would give you the "rating invalid" message instead of the E rating.

Finally, the System("pause") line serves no real purpose.

Thanks again for the help,
I had finally figured out that I was mixing char and int and did use a wile loop for the problem.
I was just coming back to update the status and read this.;)