Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Πρόγραμμα 4. Χρήση της Εντολής return ως εντολή ελέγχου. */
- #include <iostream>
- using namespace std;
- int power(int base, int exp)
- {
- int result=1;
- for(int i=1; i<=exp; i++){
- result*=base;
- }
- return result;
- }
- int main()
- {
- cout << "Give me the base." << endl;
- int a;
- cin >>a;
- cout << "Give me the exponent." << endl;
- int b;
- cin >> b;
- cout << "The result of " << a << "^" << b << " is: " << power(a,b) << " ." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement