Semoga Posting ini berguna buat temen2, meskipun sangat sederhana sekali, dan mungkin sudah umum.....
#include
#include
#include
#include
main()
{
int no,nim[17],na=0,nb=0,nc=0,nd=0,ne=0,JM=0,i,n,uts,uas,tgs,a;
char nm[20][17],ket[20];
float nil[17];
printf("Masukkan data \n");
printf("----------------\n");
printf("Jumlah Data yang akan di masukkan : ");fflush(stdin);scanf("%d",&n);
for(i=1; i<=n; i++)
{
printf("Data ke: %2d",i);
printf("\n");
printf("Nomor Pokok Mahasiswa :");fflush(stdin);scanf("%d",&nim[i]);
printf("Nama :");fflush(stdin);scanf("%[^\n]",&nm[i]);
printf("Nilai UTS :");fflush(stdin);scanf("%d",&uts);
printf("Nilai UAS :");fflush(stdin);scanf("%d",&uas);
printf("Nilai Tugas :");fflush(stdin);scanf("%d",&tgs);
nil[i]=(0.3*uts)+(0.5*uas)+(0.2*tgs);
}
printf("\n");
printf(" ==DAFTAR NILAI MAHASISWA== \n");
printf("------------------------------------------------------------------\n");
printf("| Nim | Nama | Nilai | Nilai Huruf |\n");
printf("-------------------------------------------------------------------\n");
for (i=1;i<=n;i++)
{
if(nil[i]<80>=65)
{
strcpy(ket,"B");nb++;JM++;
}
else
{
if(nil[i]<65>=56)
{
strcpy(ket,"C");nc++;JM++;
}
else
{
if (nil[i]<56>=50)
{
strcpy(ket,"D");nd++;JM++;
}
else
{
if (nil[i]<50)
{
strcpy(ket,"E");ne++;JM++;
}
else
{
strcpy (ket,"A");na++;JM++;
}}}}
printf("| %3d | %10s | %2.2f | %s |\n",nim[i],nm[i],nil[i],ket);
}
printf("--------------------------------------------------------------\n");
printf("Nilai A : %3d orang \n",na);
printf("Nilai B : %3d Orang \n",nb);
printf("Nilai C : %3d orang \n",nc);
printf("Nilai D : %3d orang \n",nd);
printf("Nilai E : %3d orang \n",ne);
printf("Jumlah Mahasiswa : %3d orang \n",JM);
printf("\n");
printf(" =====by d34fl4=====");
return (0);
}
20 November 2008 pukul 05.29
Hmm nice post :D