Pertemuan Ke-5, Kasus 5.3

Buatlah fungsi untuk menghasilkan nilai x^y.

Flowchart :
Program Dev C++ :

#include <iostream>
#include <math.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
float pangkat(int x, int y){
return (exp(y*log(x))); }
int main(int argc, char** argv) {
float hasil;
int a,b;
cout<<"\t\tMenghitung 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;
}


Comments

Popular posts from this blog

Program Menghitung Hambatan Seri dan Pararel

Menghitung nilai ipk mahasiswa

Contoh Class Dalam Bahasa C++ (Program dan Penjelasan)