Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to convert char digit to int in C++

Learn & Practice SQL


126 views
asked Apr 2, 2017 by avibootz
edited Apr 3, 2017 by avibootz

2 Answers

0 votes
#include <iostream>

using namespace std;

int main()
{
	char ch = '3';

	int n = ch - '0';

	cout << n << endl;

	return 0;
}

/*
run:

3

*/

 





answered Apr 2, 2017 by avibootz
0 votes
#include <iostream>

using namespace std;

int main()
{
	char ch = '5';

	int n = ch - 48;

	cout << n << endl;

	return 0;
}

/*
run:

5

*/

 





answered Apr 2, 2017 by avibootz

Related questions

1 answer 85 views
85 views asked May 29, 2020 by avibootz
2 answers 138 views
138 views asked Apr 1, 2017 by avibootz
2 answers 139 views
3 answers 169 views
169 views asked Apr 3, 2017 by avibootz
2 answers 122 views
...