Monday, 16 March 2015

Mencari bilangan pangkat

#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 *= a;
            }
            return hasil;
      }     

int main(int argc, char *argv[])
{
    cout<<pangkat(2,3)<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

No comments:

Post a Comment

Konversi Suhu

#include <iostream> #include <conio.h> //#include <cstdlib> //#include <iostream.h> void main( float Celcius, Kelvi...