Question #262260

Suppose m and r are integers. Write two different ways of C++ expression for mr2,store the result to variable result. The other expression uses the math function for r2 and the other doesn’t use the math



function but the equivalent expression

Expert's answer

#include <iostream>
#include <cmath>
using namespace std;


int main()
{
    int m=10,r=8,result;
    result=m*(r*r);
    result=m*pow(8,2);
    cout << "result: " << result<<endl;
    return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS