Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

Please send me answer of this question immediately and i will give you like sure sir

[画像:6. Improve the stringToInteger function to convert an entire string of digits to a non- negative integer. For example, "345" should be converted to 345. Hint: Use a loop to process the characters sequentially. Hint: You can use the length () function to determine how many characters are in a string variable. A somewhat irrelevant example is: if(i <str.length()) くろまる くろまる 7. Improve your function to handle bad strings, i.e., ones that are not all digits. Start by declaring a constant of type int named INVALID_COORDINATE and give it a value of -1. Make it a global constant by putting it before the main function (and before the function prototype). You will return this constant from stringToInteger as an error value whenever the input string is bad. くろまる 8. Change the stringToInteger function to return INVALID_COORDINATE if the string has a length of 0. Also return INVALID_COORDINATE if any character in the string is not a digit. Hint: You can use a FOR loop to access the characters in a string one by one. Hint: You can compare characters with comparison operators such as < and >=. Anything less than '0' or greater than '9' is not a digit. くろまる Reminder: If a function has a return type, it should always return a value. If the computer ever reaches the end of your function without a return statement, it will return an apparently random value (whatever is handy in memory) instead. This problem causes weird bugs. The easiest way to avoid this problem is make the last line of your function a return statement. くろまる 9. Improve your main function so there is at least one test on a bad string.]
expand button
Transcribed Image Text:6. Improve the stringToInteger function to convert an entire string of digits to a non- negative integer. For example, "345" should be converted to 345. Hint: Use a loop to process the characters sequentially. Hint: You can use the length () function to determine how many characters are in a string variable. A somewhat irrelevant example is: if(i <str.length()) くろまる くろまる 7. Improve your function to handle bad strings, i.e., ones that are not all digits. Start by declaring a constant of type int named INVALID_COORDINATE and give it a value of -1. Make it a global constant by putting it before the main function (and before the function prototype). You will return this constant from stringToInteger as an error value whenever the input string is bad. くろまる 8. Change the stringToInteger function to return INVALID_COORDINATE if the string has a length of 0. Also return INVALID_COORDINATE if any character in the string is not a digit. Hint: You can use a FOR loop to access the characters in a string one by one. Hint: You can compare characters with comparison operators such as < and >=. Anything less than '0' or greater than '9' is not a digit. くろまる Reminder: If a function has a return type, it should always return a value. If the computer ever reaches the end of your function without a return statement, it will return an apparently random value (whatever is handy in memory) instead. This problem causes weird bugs. The easiest way to avoid this problem is make the last line of your function a return statement. くろまる 9. Improve your main function so there is at least one test on a bad string.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education