Friday, October 20, 2017

MENCARI NILAI TERBESAR ARRAY

#include <stdio.h>

int main (){
    int a, b, baris, kolom, jml, maks,minim;
    printf("\t\tBILANGAN ARRAY TERBESAR\n");
    printf("__________________________________________________\n\n");
        printf (" Input banyaknya baris : "); scanf ("%d",&baris);
        printf (" Input banyaknya kolom : "); scanf ("%d",&kolom);

    int c[baris][kolom];
    printf("__________________________________________________\n");
        printf ("\n Masukkan angka ke dalam matriks : ");
        printf ("\n");
        for (a=0;a<baris;a++){
            for(b=0;b<kolom;b++){
                printf (" Baris [%d] Kolom [%d]: ",a+1,b+1); scanf ("%d",&c[a][b]);
        }
    }
        printf ("\n");
        for (a=0;a<baris;a++){
            for(b=0;b<kolom;b++){
                printf (" %d ",c[a][b]);
        }
        printf("\n");
    }

        jml=0;
        for (a=0;a<baris;a++){
            for(b=0;b<kolom;b++){
              jml=jml+c[a][b];
            }
        }
        printf("\n Nilai yang di input : %d ", jml);
        printf ("\n");

        maks=0;
        for (a=0;a<baris;a++){
            for(b=0;b<kolom;b++){
                    if(c[a][b]>maks){maks=c[a][b];}

        }
        }
 printf("\n___________________________________________");
 printf("\n\n\t\t Hasil ");
 printf("Bilangan Terbesar %d\n\n",maks);
return 0;
}

Admin NgadidikIT

Admin & Editor

Admin Website Artikel Ngadidik Teknologi SMK, Maintenance IT

0 comments:

Post a Comment

 
biz.