Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ - 34 - Functions - Parameter ( Codes )
#1
Code:
#include <iostream>

using namespace std;
int power(int base, int power);
int main()
{
   //int res = power();
   int ba, po;
   cin >> ba;
   cin >> po;
   cout << "The return value is : " << power(ba, po) <<endl;
   return 0;
}

int power(int base, int power){
   int result = 1;
   for(int i=1;i<=power;i++){
       result*=base;
   }
   return result;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)