Senin, 26 Maret 2012

Alpro - Function (Determine the Maximum Number)

assalamu'alaikum warahmatullah..

Reflection meetings to five algorithms and programming, 

Function is a part of the program is intended to do a certain task and located separately from the program
called him. Function is a key element in the C language because the language C itself is formed from a

collection of functions. In any program language C, there is at least one function is the function main ().
I still find it difficult to make a raptor for a function but at least I have understood if the function is similar to the procedure, except that the function can return a value.

The following is one example of a function in the form of a flowchart, and I would make the program ...







explanation of the picture above:
the first image, the function main () ... where the functions are functions of the calling process to the maximum .... while the second image is a process of maximum function.




#include <iostream>
#include <string>

using namespace std;
 void maksimum (int a, int b)
{

   if (a>b)
   {
      cout << "bilangan maksimum = "<<a << endl;   }
   else
   {
      cout << "bilangan maksimum = "<<b << endl;   }
}
int main()
{
   int b;
   int a;

   cout <<"x = ";
   cin >> a;
   cout <<"y = ";
   cin >> b;
   maksimum(a,b);
system("pause");
   return 0;
}

Tidak ada komentar:

Posting Komentar