Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (bnum<0){
- cout<<setprecision(3);
- bnum = -bnum;
- for (int a=1; a<bnum; a++){
- answer=answer*anum;
- }
- ansfrac=1/answer;
- if ((int(ansfrac) != ansfrac)&& (answer > 0)){
- cout<<anum<<" to the power of "<<bnum<<" is 1/"<<answer<<" or "<<ansfrac<<"."<<endl;
- }
- else if ((int(ansfrac) != ansfrac)&& (answer < 0)){
- bnum=-bnum;
- answer=-answer;
- cout<<anum<<" to the power of "<<bnum<<" is -1/"<<answer<<" or "<<ansfrac<<"."<<endl;
- }
- else {
- bnum=-bnum;
- cout<<anum<<" to the power of "<<bnum<<" is: "<<answer<<"."<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement