Answer to Question #313810 in C++ for amna

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.


1
Expert's answer
2022-03-18T06:41:17-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog