Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write it in C++ Write a program that computes the summation between 1 and a given number. For example, if the user inputs 5

image text in transcribed

Please write it in C++

Write a program that computes the summation between 1 and a given number. For example, if the user inputs 5 the function should add 1 2+3+4 5, and return 15. The program should compute the summation in two different ways which are described below and compare if the functions produce the same result. 1. Write a function that computes the summation between 1 and a given number using a loop. 2. Write a function that computes the summation between 1 and a given number n using the following formula: .. I = (n (n + 1 ) )/2 Example of the execution: Input a number sing a loop, the result of the summation is: 15 sing Gauss' s formula, the result f the summation is 15 both mtehods give the same value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

Describe some examples of the misuse of derivatives.

Answered: 1 week ago

Question

1. In what ways has flexible working revolutionised employment?

Answered: 1 week ago