Monday, 16 March 2015

Mencari Bilangan Terbesar

#include <cstdlib>
#include <iostream>

using namespace std;
void CariElemenTerbesar(int a[], int &maks){
     int k,n;
     maks = a[0];
     n = sizeof (a);
     for(k=2;k<=n;k++){
                       if (a[k] > maks){
                               maks = a[k];
                               }
                       }
     }
int main(int argc, char *argv[])
{
    int maks;
    int a[]={7,6,13,10,8,9};
    CariElemenTerbesar(a,maks);
    cout<<endl<<maks<<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...