Answer to Question #200148 in C for Lucy

Question #200148

Write a program that converts a string like "124" to an integer 124.


1
Expert's answer
2021-05-29T03:34:23-0400
//C program that converts a string like "124" to an integer 124.
#include<stdio.h>
#include <stdlib.h>


int main() 
{
    char strNum[10] = "124";//Numeric string
    
    int intNum = atoi(strNum);//Use atoi() to convert the string to numeric integer
    
    printf("The string %s string has been converted to %d integer", strNum, intNum); //Display the results

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS