#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
int n, m, sumR, sumB, xnum, max, min, i, x, numR, numB ;
bool fail;
float mediaR;
cout << "insert the value of 'n': ";
cin >> n;
max=n;
min=n;
cout << "insert the value of 'm': ";
cin >> m;
if (m>max){
max=m;
}
if (m<min){
min=m;
}
numR=0;
sumR=0;
xnum=0;
while (numR!=100)
{
cout << "insert a number (to terminate insert 100): ";
cin >> numR;
if (!isdigit(numR)){
//fail=cin.fail(); //from here
//cin.clear();
//fail=true; // causing problems
//cin.ignore(numeric_limits<streamsize>::max(), '\n'); // to here
cout<< "that's not a numeric value\n";
numR=0;
continue;}
elseif (numR==100){
cout << "the numbers ended\n";
break;
}
else {
sumR+=numR;
xnum++;
if (numR==100 && xnum==0){
cout << "no value inserted\n";}
}
isdigit() tests a character not an integer. It tests for an ASCII representation of a digit. Your program does ever read a numerical value in the range of INT_MIN..INT_MAX, so line 30..38 are obsolete.