Selasa, 29 Mac 2016

Kasus 5.3 #Pertemuan 5

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

PROGRAM
#include <iostream>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
float pangkat(int x, int y) {
    return (exp (y*log(x)));}
    main(){
    float hasil;
    int x,y;
    cout<<"menghitung hasil perpangkatan \n";
    cout<<"tulis sebuah bilangan : ";cin>>x;
    cout<<"tulis pangkat : ";cin>>y;
    hasil=pangkat(x,y);
    cout<<x<<"pangkat"<<y<<"="<<hasil;
    
    return 0;
}
 

Load disqus comments

0 ulasan