Tugas Alpro PPT Minggu ke 4 Kasus 4.7

Menghitung Nilai dari perpangkatan dengan x bilangan real dan y bilangan bulat

Logikanya Menggunakan Raptor




Program C++

#include <cstdlib>
#include <iostream>
using namespace std;
int pangkat (int a, int n){
int k,hasil;
hasil = 1;
for(k=1;k<=n;k++){
hasil=hasil*a;
}
return hasil;
}

int main(int argc, char** argv) {
int a,n;
cout<<"=========================="<<endl<<endl;
cout<<"program perpangkatan"<<endl<<endl;
cout<<"=========================="<<endl;
cout<<"masukkan angka : ";
cin>>a;
cout<<"masukkan pangkat :";
cin>>n;
cout<<"hasil perpangkkatan ="<<pangkat (a,n);
cout<<"\n";

system("pause");
return 0;

}




Share this:

ABOUT THE AUTHOR

Ceyron Louis

A web designer from India. And then you write some more information about yourself like this to fill out the space that is left.

0 komentar:

Posting Komentar