Natural numbers a and n are entered from the keyboard. Write a program for calculating a to the power of n.

C ++ program.

#include <iostream>
using namespace std;

int main () {
setlocale (LC_ALL, “Russian”);
int n;
int a;
float st = 1;

cout << “Enter the number a” << endl;
cin >> a;

cout << “Enter number n” << endl;
cin >> n;

if (n == 0) {
st = 1;
}

else if (n> 0) {
for (int i = 0; i <n; i ++) {
st = st * a;
}
}

else if (n <0) {
n = n * (-1);
for (int i = 0; i <n; i ++) {
st = st * a;
}
st = 1 / st;
}

cout << st;
return 0;
}



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.