Display the positive even numbers

Assignment Help Basic Computer Science
Reference no: EM131218125

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;

Reference no: EM131218125

Questions Cloud

Two figures from the humanities : Write a paper and include two figures from the Humanities.-  compare and contrast their achievements.
Begin with a workstation running : A suggested approach is to begin with a workstation running a web browser and trace a connection to a public web server (i.e. facebook; eBay; etc). As part of your narrative
What is involved in performing the eight key managerial task : Explain what role a company's culture plays in executing these managerial tasks.
File size-transmission speed and transmission time : Cloud 9, a cloud storage service provider based in San Diego, has just announced that it is running out of money and will be shutting down operations soon. It has given all its clients fifteen (15) days to move their data out, either back to their..
Display the positive even numbers : 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.
Schedule deliveries from its central warehouse : Sherry's Meats, a regional meat wholesaler and retailer, needs to collect up-to-date information on how much of each meat product it has in each store. It will then use that information to schedule deliveries from its central warehouse.
What are a trade deficit and a trade surplus : What are a trade deficit and a trade surplus? What are the implications of a long-term trade deficit or trade surplus? What techniques are available to correct Balance of Payment Deficit or Surplus?
Barlow declaration of independence : How is Barlow's declaration of independence similar and different from theDeclaration of Independence (Links to an external site.)that Thomas Jefferson wrote in 1776 in terms of what each wanted to achieve for the "people" or to empower them?
What are the elements of capital budgeting : What are the elements of capital budgeting? How do you determine these elements in the global business arena? Provide examples of how you would use capital budgeting analysis to determine the desirability of global projects.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Illustrate the corresponding equivalence

Let A = {a, b, c, d, e, f} be partitioned into subsets {a, b}, {c, e, f}, and {d}. Illustrate the corresponding equivalence relation by a directed graph.

  Specific situations where dividing the ssn is useful

This exercise asks you to think about specific situations where dividing the SSN is useful.

  Imagine an online registration application

Imagine an online registration application. Use your registration form as starting point for your analysis. Identify the entities that a potential database will need, along with their attributes. Try to establish unique identifiers for the records in..

  How the records are changed

How would your answers to Exercise 10.7 change if attribute a is not a candidate key for R? How would they change if we assume that records in R are sorted on a?

  How many times each function has been called

how many times each function has been called

  Evaluates and makes recommendations to address

Evaluates and makes recommendations to address differences in ethical codes of information technology conduct in different cultures in a very clear and detailed way.

  Determine how task management is achieved in that context

Task management for OO systems can be quite complex. Do some research of OOD methods for real-time systems (e.g., [BIH92] or [DOU99]) and determine how task management is achieved in that context.

  Access mode in cisco networking

What is the difference between trunk mode and access mode in Cisco networking?

  Write a program that defines and tests a factorial function

Write a program that defines and tests a factorial function. The factorial of a number is the product of all whole numbers from 1 to N. For example, the factorial of 5 is 1*2*3*4*5=120, Help?

  Solve the following logcal problems

Solve the following logcal problems: a. 10110001 OR 00011010 b. 11100110 XOR 10111011

  Experience in programming with tree data structures

Objective: To gain experience in programming with tree data structures; to practise building larger applications from a variety of data structures; to gain awareness of managing resources (both space and time) in programming with tree data structu..

  Create a budget and chart analysis for a fictitious business

For this assignment, you will create a budget and chart analysis for a fictitious business. Its purpose is for you to learn best practices for utilizing spreadsheet software (e.g., Excel, Google Spreadsheets, etc.). The final product will consist ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd