Consider the following two code fragments for counting spaces and newlines: // Version 1 while (cin.get(ch)) //
Question:
Consider the following two code fragments for counting spaces and newlines:
// Version 1
while (cin.get(ch)) // quit on eof
{
if (ch == ' ')
spaces++;
if (ch == '\n')
newlines++;
}
// Version 2
while (cin.get(ch)) // quit on eof
{
if (ch == ' ')
spaces++;
else if (ch == '\n')
newlines++;
}
What advantages, if any, does the second form have over the first?
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 83% (6 reviews)
The advantages are 1 Congruence The for loop of versio...View the full answer
Answered By
James Warinda
Hi! I’m James Otieno and I'm an experienced professional online tutor with countless hours of success in tutoring many subjects in different disciplines. Specifically, I have handled general management and general business as a tutor in Chegg, Help in Homework and Trans tutor accounts.
I believe that my experience has made me the perfect tutor for students of all ages, so I'm confident I can help you too with finding the solution to your problems. In addition, my approach is compatible with most educational methods and philosophies which means it will be easy for you to find a way in which we can work on things together. In addition, my long experience in the educational field has allowed me to develop a unique approach that is both productive and enjoyable.
I have tutored in course hero for quite some time and was among the top tutors awarded having high helpful rates and reviews. In addition, I have also been lucky enough to be nominated a finalist for the 2nd annual course hero award and the best tutor of the month in may 2022.
I will make sure that any student of yours will have an amazing time at learning with me, because I really care about helping people achieve their goals so if you don't have any worries or concerns whatsoever you should place your trust on me and let me help you get every single thing that you're looking for and more.
In my experience, I have observed that students tend to reach their potential in academics very easily when they are tutored by someone who is extremely dedicated to their academic career not just as a businessman but as a human being in general.
I have successfully tutored many students from different grades and from all sorts of backgrounds, so I'm confident I can help anyone find the solution to their problems and achieve
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Consider the following two mutually exclusive projects: Whichever project you choose, if any, you require a 15 percent return on your investment. (a) If you apply the payback criterion, which...
-
Consider the following two mutually exclusive projects available to Global Investments, Inc.: The appropriate discount rate for the projects is 10 percent. Global Investments chose to undertake...
-
Consider the following two separate firms. One firm manufactures flexible packaging films for the snack, bakery, confectionery, and tobacco industries. Its manufacturing process has been quite stable...
-
A record company needs to produce 100 gold records at one or more of its three studios. the cost of producing x records at studio 1 is 10 x; the cost of producing y records at studio 2 is 2y 2 ; the...
-
Make a BPMN diagram of the Sandwich Making process. Assume two rolesa stationary assembler and a runner who gets the items from different spots in the kitchen.
-
A block of bits with n rows and k columns uses horizontal and vertical parity bits for error detection. Suppose that exactly 4 bits are inverted due to transmission errors. Derive an expression for...
-
In a survey of 1002 U.S. adults, 88% said that fake news has caused a great deal of confusion or some confusion. Determine whether the number is a parameter or a statistic. Explain your reasoning.
-
1. Use descriptive statistics to summarize the data from the two studies. What are your preliminary observations about the depression scores? 2. Use analysis of variance on both data sets. State the...
-
How to draft a Job Analysis for an employee's jobs in human resources. Explain the process you used and why. Explain the outcomes of the job analysis and how these outcomes would be useful in the...
-
Greenville has provided the following information from its General Fund Revenues and Appropriations/ Expenditure/Encumbrances subsidiary ledgers for the fiscal year ended. Assume the beginning fund...
-
Write a program that uses an array of char and a loop to read one word at a time until the word done is entered.The program should then report the number of words entered (not counting done).A sample...
-
Is the following statement valid? If not, why not? If so, what does it do? int x = (1,024); What about the following? int y; y = 1,024;
-
Wade Sprinkling Company produces two types of pipe: (1) Lawn sprinkler pipe and (2) Building sprinkler pipe. Relevant information for the production of the two types of pipe for 2012 is as follows:...
-
An electric circuit with a resistor, a capacitor, an inductor, and a voltage source can be described by the ODE $$ \begin {equation) L (dl\over dt} + RI+ (Q\over C} = E(t). \tag (76) \end{equation)...
-
General, Inc. has prepared the following direct materials purchases budget: Budgeted DM Purchases Month June July August September October $69,000 78,500 78,100 76,000 78,200 All purchases are paid...
-
An organization may be able to enhance service delivery efficiency and reduce administrative expenses by streamlining internal processes and removing bottlenecks. Would you say that your value stream...
-
Ann earns $6,900 per month as a gym teacher in California. Her state, local, and federal taxes represent 53% of her monthly gross income. What amount does Ann take home after taxes are deducted from...
-
To reduce an anticipated large number of applicants for a graphic designer position, a senior recruiter adds proficiency in the graphics design software she remembers learning about when she was in...
-
Discuss how performance optimizations for file systems might result in difficulties in maintaining the consistency of the systems in the event of computer crashes.
-
The Home Depot is the leading retailer in the home improvement industry and one of the 10largest retailers in the United States. The company included the following on its January 29, 2012, balance...
-
Repeat Problem 2.71 for a system that has seven sensors. Data From Problem 2.71 A given system has four sensors that can produce an output of 0 or 1. The system operates properly when exactly one of...
-
Find the minimum-cost circuit consisting only of two-input NAND gates for the function f (x 1 , . . . , x 4 ) = m(0, 1, 2, 3, 4, 6, 8, 9, 12). Assume that the input variables are available in both...
-
(a) Use a schematic capture tool to draw schematics for the following functions f 1 = (x 1 + x 2 + x 4 ) (x 2 + x 3 + x 4 ) (x 1 + x 3 + x 4 ) (x 1 + x 3 + x 4 ) f 2 = (x 2 + x 4 ) (x 3 + x 4 ) ...
-
A 2-meter-tall basketball player attempts a goal 12.4 meters from the basket that is 3.05 meters high. If he shoots the ball at a 55 angle, at what initial speed must he throw the basketball so that...
-
Find the following. 2. 3 y(t) + 3y(t) 3+ = x(t) + 3 x(t) 3. y(t) - 1/2 y(t) x(t) = dt d 4. dt d 5. dt y(t) + 1/2 y(t) + y(t) y(t) + 1/2 y(t) = x(t) + x(t) = x(t)
-
1. Who are the people affected by rsum truth decisions? 2. Why might a job seeker have a duty to blur parts of his or her work history? 3. Why might an egoist lie on the rsum, and why not? 4. Does an...
Study smarter with the SolutionInn App