# Answer to Question #24667 in C++ for alfred lontoc

Question #24667
3.Write a function integerPower(base, exponent) that returns the value of baseexponent. For example, integerPower(3,4) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer and that base is an integer. The function integerPower should use for or while to control the calculation. Do not use any math library functions. (exPo.cpp) 4.Write a function-oriented program that will perform date arithmetic; such as counting the total number of days between 6/1/1990 and 8/3/1992. (date.cpp)
#include <iostream>
#include <ctime>

int main()
{
struct tm t = { 0 };
t.tm_sec = t.tm_min = t.tm_hour = 0; // midnight
t.tm_mon = 0; // January
t.tm_year = 2012 - 1900;
t.tm_isdst = -1; // unknown

t.tm_mday = 200; // January 200th?

time_t when = mktime(&t);
const struct tm *norm = localtime(&when); // Normalized time

std::cout << "month=" << norm->tm_mon << ", day=" << norm->tm_mday << "\n";
std::cout << "The 200th day of 2012 starts " << asctime(norm);
}

#include <iostream>

#include <conio.h>

using namespace std;

long integerPower(int base, int exponent)
{
long result = 1;
while (exponent--)
& result *= base;
return result;
}

int main(int argc, char *argv[])
{
cout << "3 ^ 4 = " << integerPower(3, 4) << endl;
_getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!