Kasus 5.3

Dengan menggunakan fungsi ln dan exp, buatlah fungsi untuk menghasilkan nilai xy


#include <iostream>
#include <math.h>
using namespace std;
float pangkat(int x, int y)
{     return(exp(y*log(x)));  }
main() {
     float hasil;
     int a, b;
     cout << "Menghitung hasil perpangkatan\n";
     cout << "Tulis sebuah bilangan : "; cin >> a;
     cout << "Mau dipangkat berapa  : "; cin >> b;
     hasil = pangkat(a,b);
     cout << a << " pangkat " << b << " = "  << hasil;
     return 0;  
}

 

 

Previous
Next Post »
Copyright © 2015 Bettong'rs All Right Reserved
Created by Arlina Design Powered by Blogger