okay, I need some help, I need to write a program where I can enter a first number, then a second one, and it raises the second one to the first one, only problem is I don't know how to do powers, if some one could write me a short quick example it would be much appreciated.
edit: here is my code so far, but it isnt working for some reason, could be because I'm not doing the powers right
Code:#include <iostream> #include <cmath> using namespace std; void powfun(int, int); int main() { int exp, fnum; cout << "Please enter an interger for an exponent" << endl; cin >> exp; cout << "Now please enter an interger to be raised" << endl; cin >> fnum; powfun(exp, fnum); system("pause"); return 0; } void powfun(int exp, int fnum) { cout << fnum << "Raised to the power of " << exp << " is " << fnum ^ exp << endl; return; }
my second problem is basically to write a program that converts time passed (since program was opened) into the equivilant hours mins and seconds, this is what i have so far and it doesn't really work. basically it kind of counts the seconds, but not exactly
thanks for any help in advanceCode:#include <iostream.h> #include <time.h> using namespace std; int main () { int sec_counter, min, hour, sec; for (sec_counter = 1; sec_counter <= 60; sec_counter++) { cout << "Seconds Within the for loop: " << clock()/CLOCKS_PER_SEC; system("pause"); } system("pause"); return 0; }



LinkBack URL
About LinkBacks


