Recursive Implementation of atoi ( ) | Recursive C # program to compute atoi ( ) ; Recursive function to compute atoi ( ) ; Base case ( Only one digit ) ; If more than 1 digits , recur for ( n - 1 ) , multiplu result with 10 and add last digit ; Driver code
using System ; class GFG { static int myAtoiRecursive ( string str , int n ) { if ( n == 1 ) { return str [ 0 ] - '0' ; } return ( 10 * myAtoiRecursive ( str , n - 1 ) + str [ n - 1 ] - '0' ) ; } public static void Main ( ) { string str = "112" ; int n = str . Length ; Console . Write ( myAtoiRecursive ( str , n ) ) ; } }