Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part A, you will develop functions to convert a string to a row and column. As you develop them, you ill write a main function
Part A, you will develop functions to convert a string to a row and column. As you develop them, you ill write a main function to test them. erform the following steps: 1. Create a main. cpp file for your program. Inside it, put \#includes for and , a using namespace std; line, and a main function that just returns 0. 2. Your program does not do anything yet, but it should compile and run without crashing. From now on, try to keep your program in a working state. Debugging is much easier if only one thing is wrong at a time. - Hint: If you are using replit, you can compile with g++ main.cpp -o parta Then you can execute it with - /parta - Recommendation: Compile the program after every step or two from now on. 3. Print a message at the start of your main function saying that it will test place-strings. 4. Write a function named stringToInteger that take a string as its only parameter and returns an int. Place the function prototype (one line ending with a semi-colon) before the main function and the function itself after the main function. For now, it should just convert the first character in the string to an int and return that. - Hint: You can access the individual characters of a string using array syntax. For example, if your string is named str, then str [0] is the first character and str [1] is the second one. - Hint: To convert a single digit character to an integer, subtract the ' 0 ' character. For example, ' 4 ' - ' 0 ' equals 4 as an int value. So if a char variable named ch contains 4 and you subtract ' 0 ' from ch and store the result in an integer variable named j, then you will store 4 in j. 5. Add code to your main function to test your stringTo Integer function. Write at least 3 tests on different strings, including at least one with multiple digits. For each test, print a message displaying the string you are converting and the result
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started