Terminate program without exit the window

Hi, my code exit the console when the input is valid. But what i want is that it stop after showing "Invalid value !" and remain in that page, it does not exit and does not read other input. Hope you can help me.

cout << "Please enter x (gram per litre) ." << endl;
cin >> x;
if (x%5!=0.0)
{
cout << "Invalid value !"<< endl;
system ("pause");
return 0;
}
Either run your program from the console (recommended) or put your pause thing in the proper spot:

1
2
3
4
5
6
7
8
9
10
int main()
{
  do stuff.
  if (something)
  {
    do more stuff.
  }

  system("pause");
}

BTW, see http://www.cplusplus.com/forum/beginner/1988/
Topic archived. No new replies allowed.