Question

* The isinteger ) function examines the string given as its first argument, and returns true if and only if the string repres

Do it in C please, without using parseint, atoi.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

bool isInteger(char* str)

{

for (int i = 0; str[i] != '\0'; i++)

if (str[i] < '0' || str[i] > '9') {

return 0;

}

}

return 1;

}

int parseInt(char *str) {

int n = 0;

for (int c = 0; str[c] != '\0'; c++) {

n = n * 10 + str[c] - '0';

}

return n;

}

Add a comment
Know the answer?
Add Answer to:
Do it in C please, without using parseint, atoi. * The isinteger ) function examines the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings...

    using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings separated by a space. The first string will consist of the following sets of characters: +, *, $, and {N} which is optional. The plus (+) character represents a single alphabetic character, the ($) character represents a number between 1-9, and the asterisk (*) represents a sequence of the same character of length 3 unless it is followed by {N} which represents how many...

  • In C programming, Modify the function Pop in the example so that it has the signature...

    In C programming, Modify the function Pop in the example so that it has the signature                                                 bool Pop(LIST *list, char *c) and returns false if the list is empty and returns true if not empty. On success it returns the value removed from the stack in the variable c. Modify the function CheckForBalance to accommodate this change and rerun the test program giving the same output as in the example. :here is the CheckForBalance example code, the rest of...

  • Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three...

    Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three functionalities: Covert a binary string to corresponding positive integers Convert a positive integer to its binary representation Add two binary numbers, both numbers are represented as a string of 0s and 1s To reduce student work load, a start file CSCIProjOneHandout.cpp is given. In this file, the structure of the program has been established. The students only need to implement the...

  • using java String Challenge Have the function StringChallenge(str) read str which will contain two strings...

    Have the function wildcard(str) read str which will contain two strings separated by a space.The first string will consist of the following sets of characters: +, *, $ and {N} which is optional.The plus (+) character represents a single alphabetic character, the ($) character represents anumber between 1-9, and asterisk (*) represents a sequence of the same character of length 3unless it is followed by {N} which represents how many characters would appear in thesequence where N will be at...

  • Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a...

    Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...

  • Write a C++ program that simulate a menu based binary number calculator.You don't have to write the main part of the...

    Write a C++ program that simulate a menu based binary number calculator.You don't have to write the main part of the program just the two functions for my C++ program. I wanted to post the sample code from my class but it won't allow me it's too long. This calculate shall have the following five functionalities: Provide sign extension for a binary number Provide two’s complement for a binary nunber string signed_extension(string b);              // precondition: s is a string that...

  • Using C, Write a function reverse which takes a string as an argument, reverses the string...

    Using C, Write a function reverse which takes a string as an argument, reverses the string and returns the reversed string. Note; you should not return a string that you created inside the reverse function! For example: Test char str[]-"hello" printf("%s", reverse (str)); Result olleh

  • c class ex in the 2pic Question 1: A. Write a recursive function Ecursive function that...

    c class ex in the 2pic Question 1: A. Write a recursive function Ecursive function that converts a string of digits into an integer. The function returns an integer that is converted from the original string 's'. int convertToint char *s); B. What's BIG-O notation of your function in part A. charx = "1234": Sở 3 : void printlnt (charts) if( *s == '() return; printf("%. Ch, ts): 7 printlnt (5+1): Ob..

  • **C++ only and no vectors or global variables. Thank you, Write a recursive function to convert...

    **C++ only and no vectors or global variables. Thank you, Write a recursive function to convert a character string of digits to an integer. Example: convert("1234) returns 1234. Hint: To convert a character to a number, subtract the ASCII value '0' from the character, then the function can return the value s[0] - '0'.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT