Create a function called mag() using the following prototype that raises num to the order of magnitude specified by order.(use C++ language) void mag(long &num, long...

      

Create a function called mag() using the following prototype that raises num to the order of magnitude specified by order.(use C++ language)

void mag(long &num, long order);
For example, if num is 4 and order is 2, when mag() returns, num will be 400.Demonstrate in a program that the function works.

  

Answers


Davis
#include
using namespace std;
void mag(long &num, long order);
int main()
{
long n = 4;
long o = 2;
cout << "4 raised to the 2nd order of manitude is ";
mag(n, o);
cout <return 0; }
void mag(long &num, long order)
{
for( ; order; order--) num = num * 10;

Githiari answered the question on May 29, 2018 at 18:04


Next: The copy constructor is also involked when a function generates the temporary object that is used as the function's return value. With this in...
Previous: Show how to allocate a float and an int by using new. Also, show how to free them by using delete.

View More Computer Science Questions and Answers | Return to Questions Index


Exams With Marking Schemes

Related Questions