text: Convert string to integer without using any in | C program for the above approach ; Function to convert string to integer without using functions ; Initialize a variable ; Iterate till length of the string ; Subtract 48 from the current digit ; Print the answer ; Driver Code ; Given string of number ; Function Call
code: #include <stdio.h> NEW_LINE #include <string.h> NEW_LINE void convert ( char s [ ] ) { int num = 0 ; int n = strlen ( s ) ; for ( int i = 0 ; i < n ; i ++ ) num = num * 10 + ( s [ i ] - 48 ) ; printf ( " % d " , num ) ; } int main ( ) { char s [ ] = "123" ; convert ( s ) ; return 0 ; }