How to determines whether a character is a digit in C++

1 Answer

0 votes
#include <iostream>

using namespace std;

int main()
{
	
	char ch = '9';
	if (isdigit(ch))
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	ch = 'a';
	if (isdigit(ch))
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	return 0;
}




/*
run:

yes
no

*/

 



answered Dec 5, 2016 by avibootz

Related questions

1 answer 167 views
1 answer 166 views
1 answer 114 views
1 answer 180 views
1 answer 171 views
1 answer 177 views
...