Click To Get Off-Campus Placement Jobs Info !!!
Program Discussion :: Strings
Home > Programs > Strings

53 / 58

Write a program to enter the string then find the respective ascii value of the string.

Answer:

int myAtoi(char *str)
{
    int res = 0; /*Initialize result*/  
    /* Iterate through all characters of input string and update result*/
    for (int i = 0; str[i] != '\0'; ++i)
        res = res*10 + str[i] - '0';  
    /* return result.*/
    return res;
}
/*Driver program to test above function*/
int main()
{
    char str[] = "89789";
    int val = myAtoi(str);
  cout<< val;
    return 0;
}

Asked In :: IBM

Post Your Answer Here:

Name *
Email

Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here: