Berikut ini Source code mencari bilangan terbesar dalam Array..
monggo dicobi...
#include<stdio.h>
#define n 1000
void nrp();
void main()
{
int nbil, i, x[n], max=0;
nrp();
printf("Masukkan jumlah inputan : ");
scanf("%d", &nbil);
printf("\n");
for(i=1;i<=nbil;i++)
{
printf("Masukkan bilangan ke-%d : ", i);
scanf("%d", &x[i]);
}
printf("\n");
for(i=1;i<=nbil;i++)
{
if(x[i]>max)
max=x[i];
else
continue;
}
for(i=0;i<=nbil;i++)
{
if(max==x[i])
{
printf("Bilangan terbesar = %d\n",max);
break;
}
else
continue;
}
}
void nrp()
{
printf("Nama : WIAN CANIGGIA E P \n");
printf("NRP : 7410030832 \n \n");
printf("Mencari Nilai Terbesar dalam Array \n");
printf("===================================\n");
printf("\n");
}
monggo dicobi...
#include<stdio.h>
#define n 1000
void nrp();
void main()
{
int nbil, i, x[n], max=0;
nrp();
printf("Masukkan jumlah inputan : ");
scanf("%d", &nbil);
printf("\n");
for(i=1;i<=nbil;i++)
{
printf("Masukkan bilangan ke-%d : ", i);
scanf("%d", &x[i]);
}
printf("\n");
for(i=1;i<=nbil;i++)
{
if(x[i]>max)
max=x[i];
else
continue;
}
for(i=0;i<=nbil;i++)
{
if(max==x[i])
{
printf("Bilangan terbesar = %d\n",max);
break;
}
else
continue;
}
}
void nrp()
{
printf("Nama : WIAN CANIGGIA E P \n");
printf("NRP : 7410030832 \n \n");
printf("Mencari Nilai Terbesar dalam Array \n");
printf("===================================\n");
printf("\n");
}
0 komentar:
Posting Komentar