int main() { int value; // value is some positive number n int total = 0; // tot
ID: 3653600 • Letter: I
Question
int main() { int value; // value is some positive number n int total = 0; // total holds the sum of the first n positive numbers int number; // the amount of numbers float mean; // the average of the first n positive numbers cout << "Please enter a positive integer" << endl; cin >> value; if (value > 0) { for (number = 1; number <= value; number++) { total = total + number; } // curly braces are optional since there is only one statement mean = float(total) / value; // note the use of the typecast // operator here cout << "The mean average of the first " << value << " positive integers is " << mean << endl; Q ::: Modify the code so that it computes the mean of the consecutive positive integers n, n+1, n+2, . . . , m, where the user chooses n and m. For example, if the user picks 3 and 9, then the program should find the mean of 3, 4, 5, 6, 7, 8, and 9, which is 6.Explanation / Answer
coutm; if (m > n&&m>0&&n>0) { for (number = n; numberRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.