Assala’alaikum Wr. Wb.. J
Hallo, guyyss...
Pada postingan kali ini saya akan memberikan
contoh program yang menggunakan array..
#include <stdio.h>
main()
{
int i,c,jumlah,maks,minim,nilai[3],umpan=0;
char nama[3][10];
float rata2;
printf("\t\t=====| PROGRAM DAFTAR NILAI |=====\n");
for(i=0;i<=2;i++){
printf("\n\tInput Nama ke- %d
: ",i+1); scanf("%s",&nama[i]);
printf("\tInput Nilai ke- %d : ",i+1);
scanf("%d",&nilai[i]);
}
jumlah=0;
maks=0;
for(i=0;i<=2;i++){
jumlah=jumlah+nilai[i];
rata2=jumlah/3;
if(nilai[i]>maks) maks=nilai[i];
if(nilai[i]<minim) minim=nilai[i];
}
printf("\t===========================================\n");
printf("\n\t No\t\t Nama\t\t Nilai \n");
printf("\t===========================================\n");
for(i=0;i<=2;i++){
printf("\n\t %d\t\t %s\t\t %d \n",i+1,nama[i],nilai[i]);
}
printf("\n\t===========================================\n");
printf("\n\tJumlah Nilai
= %d\n",jumlah);
printf("\n\tRata-rata Nilai
= %.2f\n",rata2);
printf("\n\tNilai Maksimum
= %d\n",maks);
printf("\n\tNilai Minimum
= %d\n",minim);
printf(" \n");
printf("\n\tCari Nama : ");scanf("%d",&c);
printf("\n\t============================================\n");
for(i=1;i==1;i++) {
if(nama[i]==0);}
printf("\n\tData yang Anda
Cari : ");
printf("\n\tNama :
%s",nama[i]);
printf(" \n");
printf("\n\t''Selamat Nama
Kamu Ada ^_^'' ");
}
Hasil Program
Terimakasih sudah berkunjung ^_^
Wassalamu'alaikum Wr. Wb...
Tidak ada komentar:
Posting Komentar