Question: write a c++ program Write two versions of a program that reads a sequence of positive integers from the user, calculates their geometric mean, and

write a c++ program

Write two versions of a program that reads a sequence of positive integers from the user, calculates their geometric mean, and print the geometric mean. Notes: 1. In mathematics, geometric mean of a dataset ", $, % , ' containing positive numbers, is given by: " $ % ' ) . For example, the geometric mean of 2, 9 and 12 is equal to 6 ( 2 9 12 - = 6). 2. In order to calculate the n-th root of a number, you should call the pow function, located in the cmath library. Your two versions should read the integer sequence in two ways: a) First read the length of the sequence. For example, an execution would look like: Please enter the length of the sequence: 3 Please enter your sequence: 1 2 3 The geometric mean is: 1.8171 b) Keep reading the numbers until -1 is entered. For example, an execution would look like: Please enter a non-empty sequence of positive integers, each one in a separate line. End your sequence by typing -1: 1 2 3 -1 The geometric mean is: 1.8171

please only use while or for loops. please do not use any arrays, functions or classes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!