Summation of integers

Ebal
timer Asked: Nov 21st, 2014

Unformatted Attachment Preview

Algorithms and tips for Assignment 5 Tip: Remember to repeat your code, by giving the user the chance to run it again. Trying using a do … while loop in the following manner: Tip: All input validations should be done using while loops NOT if statements! char response; do { // code goes here cout response; } while (response == 'y' || response == 'Y'); Algorithm for question 1a 1) Declare a variable for number (e.g. num) 2) Perform input validation for number: while (num N1. Use a loop to perform the sum of the numbers entered from N1 to N2 inclusively. Finally, verify that your loop works by using the equation (on the right-hand-side) to confirm your answer. c. Write a program that prompts the user to enter a value for N1 and N2. Ensure that the user does not enter a value < 1 for N1 or N2, and that N2 > N1. Use a loop to perform the sum of the numbers entered from N1 to N2 exclusively. Finally, verify that your loop works by using the equation (on the right-hand-side) to confirm your answer. Extra Credit. 1) Estimate the value of pi. The value of pi can be approximated by using the Gregory–Leibniz series shown below: Write a program that asks the user to enter a value for n. Ensure that the user does not enter a value < 0 for n. Use a loop to estimate the value of pi from 0 to n. Output your value of pi to verify the approximation.
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Similar Content

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors