Here is the one that I've tried and it works.
//It will terminate the loop but it's NOT an Auto Infinite Loop like the you had.
//Description:
//This program asks the user to terminate an infinite loop
//with a sentinel value of any kind.
# include <iostream>
# include <cmath>
using namespace std;
int main(void){
int test = 0;
char stop;
while (test++ < 10){
cout<<"Hello \n";
cin>>stop;
if (stop == 'q') //Pressing (sentinel value) q on the keyword will terminate the program.
break;
}
cout<<"Program has been terminated! \n";
return 0;
}