برنامه ی به توان رساندن یک عدد با استفاده از ضرب به زبان سی پلاس پلاس
جمعه, ۱۶ مهر ۱۳۹۵، ۰۷:۲۶ ب.ظ
gameover.blog.ir
#include <iostream>
using namespace std;
int main() {
int exp;
float base, power = 1;
cout << "Enter base and exponent respectively: ";
cin >> base >> exp;
while (exp != 0) {
power *= base;
--exp;
}
cout << "Result = " << power;
return 0;
}
Output
Enter base and exponent respectively: 3.4 3 Result = 39.304
۹۵/۰۷/۱۶