Senin, 02 April 2012

Function - Alpro

hi friends,,, every article that I wrote like a story for me ...
This time I came back to tell the object instance that uses a variety of functions.
as usual my stories using raptors as well as C + + dev ... let's start the story!




We begin with a function to compute the rank of a number!
 flowchart!



 




Program!
#include <iostream>
#include <string>

using namespace std;
 int pangkat (int a,int b)
{
   int hasil;
   int exp;

   hasil =1;
   exp =1;
   while (!(exp>b))
   {
      hasil =hasil*a;
      exp =exp+1;
   }
   cout << "hasil = "<<hasil << endl;}
int main()
{
   int x;
   int y;

   cout <<"basis = ";
   cin >> x;
   cout <<"pangkat = ";
   cin >> y;
   pangkat(x,y);
system("pause");
   return 0;
}

Tidak ada komentar:

Posting Komentar