Pow
|
|
C# Quellcode |
1 2 3 |
double pow (double base, double exponent ); long double pow (long double base, long double exponent ); float pow(float base, float exponent ); |
|
|
C/C++ Quellcode |
1 2 3 4 5 6 7 8 |
#include <cmath> int main() { double a = 5, b = 6; double c = std::pow(a, b); return 0; } |
double a = 5, b = 6;
double c = std::pow(a, b);
----------------------------------------------------------------------------------------
Definiert a und b die zahl ist gelegt einfacher wär's wenn man a und b eingeben kann je nach bedürfniss.
|
|
C/C++ Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include <cmath> #include <iostream> int main() { double a, b; std::cout << "Value a: "; std::cin >> a; std::cout << "Value b: "; std::cin >> b; std::cout << "a^b = " << std::pow(a, b) << std::endl; return 0; } |
Vaue a: 100
Value b: 10
a^b = 1e+020Drücken Sie eine beliebige Taste . . .
so siehts aus ("verwirrend")
|
|
C/C++ Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include <iostream> void main() { int a; int b; int c; std::cout<<"Rechner"<<std::endl; std::cout<<"Rechenart auswählen (1 = Addition 2 = Subtraktion 3 = Multiplikation 4 = Division ) : "<<std::endl; std::cin>>c; std::cout<<"wert1:"; std::cin>>a; std::cout<<"wert2:"; std::cin>>b; if (c==1) std::cout<<"Die summe ist:"<<a+b<<std::endl; else if (c==2) std::cout<<"Die summe ist"<<a-b<<std::endl; else if (c==3) std::cout<<"Die summe ist:"<<a*b<<std::endl; else if (c==4) std::cout<<"Die summe ist: "<<a/b<<std::endl; else std::cout<<"Ungültige Zahl"<<std::endl; std::getchar(); } // Das ist leicht verständlich für mich . . . |