Question #313810

Write a program that will ask the user to enter a digit character (i.e. ‘0’ or ‘1’ .... or ‘9’). If user

enters a non-digit character then the program should display message to re-enter correct input.


Expert's answer

#include <iostream>

using namespace std;

int main()
{
	char c;
	do
	{
		cout << "Please, enter a digit character: ";
		cin >> c;
	} while (c < '0'|| c > '9');
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS