online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <cmath> using namespace std; int power(uint n, uint m = 2) { if (m != 0 || n !=0) // dzięki użyciu uint a nie int liczby te są traktowane zawsze jako dodatnie, więc warunek można uprościć { return pow(n, m);// to jest całkiem dobra funkcja biblioteczna robiąca potęgowanie. Użycie domyślnej wartości dla parametru m funkcji power powoduje, że w przypadku wywołania power(3) dostaniesz to, co chcesz. } //coś wypada zwrócić jak oba parametry są zerami, np -1 aby oznaczyć błąd return -1; } int main() { int n,m,wynik; cout<<"Podaj podstawę potęgi:"; cin>>n; char addExp; cout<<"Czy chcesz podać wykładnik?(t/n):"; cin >> addExp; if(addExp = 'n') { wynik=power(n); } else { cout << "Podaj wykładnik potęgi:"; cin>>m; wynik=power(n,m); } cout<<"Wynik:"<< wynik; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue