Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question will be manually graded; it will show as a 0/16 in your score until it is graded. This question has three parts: A),

image text in transcribed
This question will be manually graded; it will show as a 0/16 in your score until it is graded. This question has three parts: A), B), and O. The following code segment reads a string (consists of letters and digits) from the keyboard and counts how many ' O ' 5 are in the string string atr; int zerocount=0: getline (cin,str) ; for(int1=0;1=str.length()1;1++)1if(str[1]=0)zeroCount++; Hint: If you are not familair with length() function, str.length() returns the number of actual characters in a string, and does not count the null character at the end of the string. Ex. string str = "Arizona"; str.length() is 7 (Arizona is 7 characters). You need to write 3 different pieces of code. Do not merge all answers into one program. A) Rewrite the above code using a while loop. [5 Points] B) Modify the above code (code given or your answer to part A above, your choice) so that it count how many digits are in the string. ASCll values for digits are values are between 48-57.' 0 ' is 48 and ' 9 ' is 57 in ASCll values. The 5tring may contain both digits and other characters, so you need to check each character one by one. Example: If the given input string is a 12b34, the total digits is 4. [5 Points] C) Write a C++ code segment that reads integers from the keyboard until user enter 0 and determine the largest. integer entered. There may be any number of inputs before the user enters 0 , including no inputs at all. 0 is countec as part of the input and should be shown as the largest integer if this is the case. [ 6 Points]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions