Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- double stepen (double x,double n)
- {
- double s=x;
- if (n>0)
- {
- for (int i=1; i<n; i++)
- {
- s*=x;
- }
- }
- else
- {
- for (int i=1; i>n; i--)
- {
- s/=x;
- }
- }
- return s;
- }
- int main ()
- {
- double a,b;
- cout<<"Unesite dva broja sa tastature (broj i stepen): ";
- cin>>a>>b;
- double x=stepen(a,b);
- cout<<x<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement