Complete the following program (including the missing semicolons) so it prints t
ID: 3769008 • Letter: C
Question
Complete the following program (including the missing semicolons) so it prints the root mean square (RMS) of all even integers between “a” and “b” (inclusive). To find the RMS of a set of numbers, square all numbers in the set, then find the arithmetic mean of the squares and take the square root of the result.
#include<iostream>
#include<cmath>
using namespace std; // can use sqrt( ) for the square root
myfunction( )
{
float
do {
} while ( );
return
} int main()
{ float a = 100, b = 200, ;
= myfunction(a, b);
cout
return 0;
}
Explanation / Answer
#include<iostream>
#include<cmath>
using namespace std; // can use sqrt( ) for the square root
float myfunction(float a, float b)
{
float s=0;
do
{
s=s+a;
a=a+2;
} while (a<=b);
return (s/100);
}
int main()
{
float a = 100, b = 200, av;
av= myfunction(a, b);
cout<<sqrt(av);
return 0;
}