Given a string str representing a string, the task is to convert the given string into an integer.
Input: str = “1234”
Input: str = “0145”
Approach: Write a recursive function that will take the first digit of the string and multiply it with the appropriate power of 10 and then add the recursive result for the substring starting at the second index. The termination condition will be when the passed string consists of a single digit. In that case, return the digit represented by the string.
Below is the implementation of the above approach:
- Convert a String to Integer Array in C/C++
- Convert given integer X to the form 2^N - 1
- Given a string and an integer k, find the kth sub-string when all the sub-strings are sorted according to the given condition
- Print reverse of a string using recursion
- Program for length of a string using recursion
- Minimum number of given operations required to convert a string to another string
- Convert string X to an anagram of string Y with minimum replacements
- Convert the string into palindrome string by changing only one character.
- Product of nodes at k-th level in a tree represented as string using Recursion
- Convert Hexadecimal value String to ASCII value String
- Minimum number of operations to convert array A to array B by adding an integer into a subarray
- Program to check if input is an integer or a string
- Rearrange a string in sorted order followed by the integer sum
- Rearrange a string in the form of integer sum followed by the minimized character
- Check if a given string is a valid number (Integer or Floating Point) in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.