The following code is supposed to display the positive even numbers less than 12. That is,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be. Then write a small program including the code below and make the necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the output. Hint: Use variable diagrams to trace the program to help you find the logical error. int x = 1; while (x != 12) { cout < < x < < endl; x = x + 2; Submit your program and output. The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be. Then write a small program including the code below and make the necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the output. Hint: Use variable diagrams to trace the program to help you find the logical error. int x = 1; while (x != 12) { cout < < x < < endl; x = x + 2; Submit your program and output.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Could you please help complete the following java code. Help is needed where //*** is throughout the code. import java.util.Arrays; import java.util.Random; import java.util.Scanner; // // Project 3...
-
On March 19, Modern Kitchens, a retail store, received Credit Memorandum 244 for $4,290 from J & M Appliance Corporation. The credit memorandum covered a return of damaged trash compactors originally...
-
A police department has set up a speed enforcement zone on a straight length of highway. A patrol car is parked parallel to the zone, 200feet from one end and 150feet from the other end (see figure)....
-
Furniture.com uses automated shipping equipment. Assume that early in year 1, Furniture purchased equipment at a cost of $400,000. Management expects the equipment to remain in service for five...
-
Jupiter, with an inertia 317.83 times that of Earth, is at an average distance of \(7.784 \times 10^{11} \mathrm{~m}\) from the Sun. At what distance from the centre of the Sun is the center of mass...
-
The venture investors and founders of ACE Products, a closely held corporation, are contemplating merging the successful venture into a much larger diversified firm that operates in the same...
-
A ( n ) _ _ _ _ _ _ _ _ _ _ contains information about a given person, product, or event. Attribute Column Field Record
-
Clovis Company recently issued $500,000 (face value) bonds to finance a new construction project. The company's chief accountant prepared the following bond amortization schedule: Required: 1....
-
A car of mass 1300 kg is travelling along a straight level road at 10 ms when the traffic lights change from green to amber. The driver applies the brakes 23 metres from the lights and just manages...
-
Using the McNaughton-Yamada-Thompson Algorithm, construct an NFA from the regular expression (= {0, 1}): 0((0|1)*1)*1 a) Draw a state graph for the NFA. b) Construct the state transition table for...
-
Diagram a calorie counting program that calculates the total weekly calories for breakfast. The diagram should allow the user to input the number of calories consumed each day for seven days, then...
-
How do protagonists in Bildungsroman and coming-of-age narratives undergo psychological and moral growth, grappling with the challenges of self-discovery, autonomy, and individuation as they...
-
2. For each of the instructions highlighted (boldface), derive the effective address of the memory variable (source) if any memory variable is involved, and the contents of the register a or d...
-
How do postcolonial protagonists negotiate issues of cultural hybridity, displacement, and identity formation, grappling with the legacies of colonialism and the complexities of navigating multiple...
-
Two out-of-town firefighting crews have been called to a wildfire in the mountains. The Alum Creek Fire Station is 96 mi from the fire and the Shelton Fire Station is 88 mi from the fire. The fire...
-
A consultant is beginning work on three projects. The expected profits from these projects are $50,000, $72,000, and $40,000. The associated standard deviations are $10,000, $12,000, and $9,000....
-
Kent Pham, CPA, is a 45-year-old single taxpayer living at 169 Trendie Street, La Jolla, CA 92037. His Social Security number is 865-68-9635. In 2012, Kent's W-2 as the controller of a local...
-
Quince Corporation has taxable income of $450,000 for its 2012 calendar tax year. Calculate the corporation's income tax liability for 2012 before tax credits. $_________
-
Jan has two jobs during 2012. One employer withheld and paid FICA taxes on $66,600 of Jan's salary, and the other employer withheld and paid FICA taxes on $44,400 in salary paid to Jan. Calculate the...
-
Resource leveling is a method to: a. Make sure everyone working on the project has approximately the same amount of work to accomplish b. A technique in which start and finish dates are adjusted...
-
When are the resource requirements estimated? a. After the activities have been defined but before the schedule has been developed b. After the schedule has been developed but before the activities...
-
Resources should be estimated against which entity: a. The deliverables level of the WBS b. Critical project constraints c. The Risk Breakdown Structure d. The schedule activities
Study smarter with the SolutionInn App