The atoi() function takes a string (which represents an integer) as an argument and returns its value.
We have discussed iterative implementation of atoi(). How to compute recursively?
We strongly recommend you to minimize your browser and try this yourself first
The idea is separate the last digit, recursively compute result for remaining n-1 digits, multiply the result with 10 and add the obtained value to last digit.
Below is the implementation of the idea.
This article is contributed by Narendra Kangralkar. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Write your own atoi()
- Recursive Functions
- Modular exponentiation (Recursive)
- Recursive Bubble Sort
- Recursive Insertion Sort
- Morse Code Implementation
- Implementation of Affine Cipher
- Recursive program for prime number
- Recursive function to do substring search
- Recursive program to generate power set
- Recursive Program for Binary to Decimal
- Recursive Practice Problems with Solutions
- Bitwise recursive addition of two integers
- Recursive program to print all subsets with given sum
- Recursive program to find all Indices of a Number
Improved By : fhu004