total back in the program. 2. What happens if you enter a float such as 4.58 instead of an integer for value? Try it and record the results. > value; if (value > 0) { for (number = 1; number (total) /...


<< endl; return<br>0;<br>}<br>Questions<br>1. Why is the typecast operator needed to compute the mean in the statement mean =<br>static_cast(float)(total)/value? What do you think will happen if it is removed? Modify<br>the code and try it. Record what happens. Make sure that you try both even and odd<br>cases. Now put static_cast<float> total back in the program.<br>2. What happens if you enter a float such as 4.58 instead of an integer for value? Try it<br>and record the results.<br>

Extracted text: < endl;="" return="" 0;="" }="" questions="" 1.="" why="" is="" the="" typecast="" operator="" needed="" to="" compute="" the="" mean="" in="" the="" statement="" mean="static_cast(float)(total)/value?" what="" do="" you="" think="" will="" happen="" if="" it="" is="" removed?="" modify="" the="" code="" and="" try="" it.="" record="" what="" happens.="" make="" sure="" that="" you="" try="" both="" even="" and="" odd="" cases.="" now="" put=""> total back in the program. 2. What happens if you enter a float such as 4.58 instead of an integer for value? Try it and record the results.
// This program has the user input a number n and then finds the I/<br>mean of the first n positive integers.<br>#include <iostream><br>using namespace std;<br>UM<br>int main()<br>{<br>int value;<br>int total = 0;<br>Il value is some positive number n<br>Il total holds the sum of the first n<br>//positive numbers<br>Il the amount of numbers float mean;<br>/ the average of the first n positive<br>I/ numbers<br>int number,<br>cout << > value; if (value > 0) { for (number = 1; number <= value;="" number++)="" {="" total="total" +="" number;="" mean="">(total) / value; note the use of the typecast operator here < "the="" mean="" average="" of="" the="" first="">< value="" cout="">< "positive="" integers="" is="">< mean="">< endl;="" }="" else="" cout="">< "invalid="" input="" -="" integer="" must="" be="" positive"="" ao="" "/="">
Extracted text: // This program has the user input a number n and then finds the I/ mean of the first n positive integers. #include using namespace std; UM int main() { int value; int total = 0; Il value is some positive number n Il total holds the sum of the first n //positive numbers Il the amount of numbers float mean; / the average of the first n positive I/ numbers int number, cout < "please="" enter="" a="" positive="" integer"="" cin="">> value; if (value > 0) { for (number = 1; number <= value;="" number++)="" {="" total="total" +="" number;="" mean="">(total) / value; note the use of the typecast operator here < "the="" mean="" average="" of="" the="" first="">< value="" cout="">< "positive="" integers="" is="">< mean="">< endl;="" }="" else="" cout="">< "invalid="" input="" -="" integer="" must="" be="" positive"="">

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here