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

  Maximum number of non zero elements

A lower triangular matrix is an nxn array in which has a[i][j] = = 0 if i

  Demonstrate an ability to communicate ideas

What kind of study does the question suggest (empirical--e.g., ethnography, case study, descriptive study, experimental; historical--oral or archival or both; theoretical; discourse or textual analysis, etc.) -  What data do you need to collect

  Implement this calculator in marie assembly

Use the Push and Pop subroutines from the previous task to implement the stack. It is a requirement that your calculator can handle any valid RPN expression, no matter how many operands and operators, and no matter in what order (up to the size of..

  Understand the definition of np

Remarks: For this question, it is important to understand the definition of NP, and the definitions of some of the standard NP-complete problems (Vertex Cover, Set Cover, Independent Set, Hamiltonian Path, etc.)

  What is the necessity of including idf in the weight

What is the necessity of including IDF in the weight of a term?

  Passing an "in out" parameter to a procedure

In Ada, when passing an "in out" parameter to a procedure, the system is allowed to use either pass-by-reference or pass-by-value-result as it sees fit. Why?

  Perform insert using binomial queues

Give an algorithm to build a binomial queue of N elements, using at most N - 1 comparisons between elements.  Propose an algorithm to insert M nodes into a binomial queue of N elements in O(M + log N) worst-case time. Prove your bound. Write an ef?ci..

  The throughput of your file server can be improved

A few days later, however, you are not surprised when your manager expresses disappointment that the SCSI-3 upgrade does not seem to be delivering the performance improvement that she expected. What happened? How can you fix it?

  Approach appropriate for company forefront of technology

However, adopting a secondary approach where others adopt early and a firm learns from their mistakes is often a viable strategy. When is each approach most appropriate and why?

  What is the percentage of compression you achieve above

What is the percentage of compression you achieve above? (This is the average of the compression percentages achieved for each letter, weighted by the letter's frequency.)

  Recognize each dependency by type using code

Recognize each dependency by type; write the two instructions involved; recognize which instruction is dependent; and name storage location involved.

  Summarizing and describing the information

Write a 1,000 word paper in APA format, summarizing and describing the information you found about tips on how to create digital presentations and how to create online presentations. Include at least 3 citations and references.

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