Calculate sum of first four positive even integers

Assignment Help Basic Computer Science
Reference no: EM132323133

The following code is intended to calculate the sum of the first five positive even integers starting at 2.

int sum = 2; 

int k;

for(k = 4; k <= 12; k += 2)

{

    sum += k;

}

What is wrong with this code segment?

A. The segment calculates the sum of the first four positive even integers.

B. The segment calculates the sum of the first six positive even integers.

C. The segment calculates the sum of the first seven positive even integers.

D. The variable sum is incorrectly initialized. The segment would work correctly if sum was initialized to 0.

E. The segment works as intended.

Reference no: EM132323133

Questions Cloud

Hci methods of usability inspections : 1. List and explain in detail the two different HCI methods of usability inspections.
Detail explanation of this incremental mining : Suppose that we have an existing transaction database TDB for which we have already mined the frequent patterns.
Characteristics of constraint such as monotone : Please explain the characteristics of each constraint such as monotone, anti-monotone, succinct, convertible etc.
Compute cost of goods sold by the weighted-average method : Compute cost of goods sold by the weighted-average method. Round average cost per unit to the nearest cent and all other amounts to the nearest dollar.
Calculate sum of first four positive even integers : The following code is intended to calculate the sum of the first five positive even integers starting at 2.
Numerical order and print the resulting array : How to Write n assembly procedure to sort the following array into numerical order and print the resulting array.
Comma and print out foods : function that asks the user for their 2 favorite foods separated by a comma and print out those foods. This function should be called in the main function.
Find the foci vertices and center of the new ellipse : Assignment - Solve the problems and write the solution in LaTeX: Find the foci, vertices, and center of the new ellipse
How to link the a web form in visual studio : Can some one show how to link the a web form in Visual Studio C# to a database.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Personal and corporate spiritual formation

How does this align with your view of personal and corporate spiritual formation?

  Describe the three principles of direct manipulation

Describe the three (3) principles of direct manipulation and give examples as to how they are used in video game controls.

  Declare an arraylist named taxrates

Declare an ArrayList named taxRates of five elements of type Double and initialize the elements (starting with the first) to the values 0.10 , 0.15 , 0.21 , 0.28 , 0.31 , respectively.

  Why must the bit map for file allocation be kept on storage

Consider a system that supports the strategies of contiguous, linked, and indexed allocation. What criteria should be used in deciding which strategy is best utilized for a particular file?

  What is the corresponding risc-v assembly code

For the following C statement, what is the corresponding RISC-V assembly code?

  How much money can you withdraw for the next

How much money can you withdraw for the next 21 years in equal annual end-of-the-year cash flows if you invest the money at a rate of 6.94 percent per year

  Discuss some technological and social implications

It has been estimated that the amount of digital data is doubling every two years. Discuss some technological and social implications and issues associated.

  Evolution of a data warehouse

Briefly describe the factors which have led to the evolution of a data warehouse?

  Managing files and the world of windows

Managing Files and the World of Windows" Please respond to the following: Take a position on whether or not standardization and naming conventions are critical for properly managing files and folders in a Windows environment. Include at least one..

  Practice what you are learning in class

What sort of opportunities do you have, or can you find or create in future, to practice what you are learning in class?

  How do ordinary and smoothed bootstrap distributions differ

In Section 3.3, we performed a permutation test to determine if men and women consumed, on average, different amounts of hot wings.

  Class and calculate the class average

Write a C++ program segment that reads 40 exam scores of a class and calculate the class average, then print the class average using a loop. you need to declare a the variables properly.

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