As integer can be positive and negative, here two cases arise.
Case#1: If string is positive
If user inputs "12312", then it should give output 12312 as an int number
Case#2: If string is negative
If user inputs "-47939", then it should give output -47939 as an int number.
Case#3: If string contains alphabetic character like "12ab6", it should print an error.
We will traverse the character array as we know String is the array of character.
Step#1: int_value = 0;
Step#2: Traverse the Character array from right to left.
Step#3: Find the place_value of the Character because the ASCII value is different of character to string.
Step#4: Multiplying the place value by 10 each time and add to sum.
int_value = int_value + place_value * 10;
For suggestions/doubts, please put your comments.