• Posted by : deari q Senin, 31 Maret 2014



    Program C++
    #include <cstdlib>
    #include <iostream>

    using namespace std;

    int main (int argc, char *argv[])
    {
    int  N, nilai, i;
    int maks=1;
    int min=1;
        cout << " Mencari nilai maksimum dan minimum" << endl;
        cout << " Masukkan nilai N : ";
        cin>>N;
        cout<<endl;
                    for (i=1; i<=N; i++){

                    cout << " Masukkan nilai: ";
                    cin>>nilai;
                                     if ( i == 1 ) {
                                             min = nilai;
                                             maks = nilai;
                                     }
                                    else if ( min > nilai ) {
                                             min = nilai;
                                    }
                                    else if ( maks < nilai) {
                                             maks = nilai;
            }      
                    }
       
        cout << "Nilai minimal        :  "  <<min<<endl;
        cout << "Nilai maksimum   :  " <<maks<<endl;

                    system("pause");
                    return 0;
    }

    hasil run 

    Leave a Reply

    Subscribe to Posts | Subscribe to Comments

  • - Copyright © 2013 Kampus - To Aru Kagaku no Railgun - Powered by Blogger - Designed by Johanes Djogan -