C++ Program For char to int Conversion Last Updated : 26 May, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In C++, we cannot directly perform numeric operations on characters that represent numeric values. If we attempt to do so, the program will interpret the character's ASCII value instead of the numeric value it represents. We need to convert the character into an integer.Example:Input: '9'Output: 9Explanation: The character '9' is converted into integer.In C++, there are several ways to convert a character to an integer:Using ASCII Code ConversionC++ uses the ASCII character set, which uses a 7-bit integer (ASCII values) to represent 128 characters. It stores the numeric (digit) characters in a sequential manner. The ASCII value of '0' is 48, '1' is 49, and so on up to '9' as 57. So, by subtracting the character '0' from a character representing a digit, we can convert the character to integer.Example: C++ #include <bits/stdc++.h> using namespace std; int main() { char ch = '9'; // Converting the char // to integer int num = ch - '0'; cout << num; return 0; } Output9If you want to convert multiple characters representing multi-digit number, refer to the following article - Convert String to int in C++Using atoi() FunctionIn C++, we can also use the atoi() function to convert a character into an integer; it takes a pointer to a character as an argument.Example: C++ #include <bits/stdc++.h> using namespace std; int main() { char ch = '9'; // Converting the char // to integer int num = atoi(&ch); cout << num; return 0; } Output9 Comment More infoAdvertise with us Next Article C++ Program For int to char Conversion L laxmigangarajula03 Follow Improve Article Tags : C++ Programs C++ C Conversion Programs Practice Tags : CPP Similar Reads C++ Program For int to char Conversion In this article, we will learn how to convert int to char in C++. For this conversion, there are 5 ways as follows: Using typecasting.Using static_cast.Using sprintf().Using to_string() and c_str().Using stringstream. Let's start by discussing each of these methods in detail. Examples: Input: N = 65 6 min read C++ Program For String to Long Conversion In this article, we will learn how to convert strings to long in C++. For this conversion, there are 3 ways as follows: Using stol()Using stoul()Using atol() Let's start by discussing each of these methods in detail. Example: Input: s1 = "20" s2 = "30" Output: s1 + s2 long: 50 1. Using stol() In C++ 3 min read C++ Program For String to Double Conversion There are situations, where we need to convert textual data into numerical values for various calculations. In this article, we will learn how to convert strings to double in C++. Methods to Convert String to Double We can convert String to Double in C++ using the following methods: Using stod() Fun 3 min read C++ Program For Hexadecimal To Decimal Conversion The hexadecimal numbers are base 16 numbers that use 16 symbols {0, 1, 2, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} to represent all digits. Here, (A, B, C, D, E, F) represents (10, 11, 12, 13, 14, 15). Decimal numbers are base 10 numbers with 10 symbols to represent all digits. In this article, we will l 3 min read How to Convert Char Array to Int in C++ In C++, a character array is treated as a sequence of characters also known as a string. Converting a character array into an integer is a common task that can be performed using various methods and in this article, we will learn how to convert char array to int in C++. Example Input:char arr1[] ="1 2 min read How to Convert ASCII Value into char in C++? In C++, ASCII (American Standard Code for Information Interchange) values are numerical representations of characters that are used in the C++. In this article, we will learn how to convert an ASCII value to a char in C++. Example: Input: int asciiValue = 65; Output: Character for ASCII value 65 is: 2 min read Like