[c++]Menentukan nilai minimum atau maksimum

 

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>main()
{int awal, akhir, i,nx, bilangan[10], dummy;

printf(“Masukkan nilai awal : “);scanf(“%d”,&awal);
printf(“Masukkan nilai akhir : “);scanf(“%d”,&akhir);
printf(“Jumlah bilangan yang mau dimasukkan (maksimal 10) : “);scanf(“%d”,&nx);
printf(“===========================================”);

for(i=1; i<=nx;i++){

printf(“Masukkan bilangan ke-%d : “,i);scanf(“%d”,&bilangan[i]);

}

//nilai maksimum
dummy=awal; //kalo mau nyari nilai minimum awal diganti akhir;
for(i=1; i<=nx;i++){

if (bilangan[i]>dummy) dummy=bilangan[i]; //kalo nyari nilai minimum tanda > diganti <

}

printf(“Nilai maksimum : %d”, dummy);

}

One Response to “[c++]Menentukan nilai minimum atau maksimum”

  1. rockerbad Says:

    //ga ngerti ama source codenya, maap🙂
    //knapa ga kaya gini aj :

    #include
    #include
    #include
    #include
    #include main()

    int main() {

    int bilangan[10], dummy, nx;

    printf(”Jumlah bilangan yang mau dimasukkan (maksimal 10) : “);scanf(”%d”,&nx);
    printf(”===========================================”);

    for(int i=0; i<nx;i++){

    printf(”Masukkan bilangan ke-%d : “,i);scanf(”%d”,&bilangan[i]);

    }

    //nilai maksimum
    dummy=0;

    //kalo mau nyari nilai minimum awal diganti akhir;
    for(i=0; idummy) dummy=bilangan[i]; //kalo nyari nilai minimum tanda > diganti <

    }

    printf(”Nilai maksimum : %d”, dummy);

    return 0;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: