Menghitung Nilai Akhir Mata Kuliah

04.31 jalankaki 0 Comments


Contoh Source Codenya :

#include <stdio.h>

char grade(int);
int akhir(int,int,int),i=0;

struct dok{
char nama [500];
int tgs, uts, uas;
};
void a(struct dok[]);
void b(struct dok[]);
main(){
struct dok data[500];
int j=0,bnyk=0;
printf("\t\t --> MENGHITUNG NILAI AKHIR MATA KULIAH <-- \n");
printf("\t\t\tKONSEP PEMROGAMAN\n\n");
printf("=================================================================\n");
printf("Masukkan jumlah mahasiswa = ");
scanf("%d",&bnyk);
fflush(stdin);
printf("Masukkan data mahasiswa\n");
while(j<bnyk){
printf("\nMahasiswa ke-%d\n",j+1);
a(data);
fflush(stdin);
j++;
i++;
}
b(data);
printf("\n\nTotal Mahasiswa = %d\n",i);
}

char grade(int n){
if(n>=80){
return 'A';
}else if(n<80&&n>=70){
return 'B';
}else if(n<70&&n>=60){
return 'C';
}else if(n<60&&n>=50){
return 'D';
}else{
return 'E';
}
}
int nilai_akir(int tgs,int uts,int uas){
return (20*tgs/100)+(40*uts/100)+(40*uas/100);
}
void a(struct dok a[]){
printf("Nama\t\t: ");
gets(a[i].nama);
printf("Nilai tugas\t: ");
scanf("%d",&a[i].tgs);
printf("Nilai UTS\t: ");
scanf("%d",&a[i].uts);
printf("Nilai UAS\t: ");
scanf("%d",&a[i].uas);
}
void b(struct dok n[]){
int j=0, akir;
printf("\n\n\t\t\t\t\tDAFTAR NILAI\n");
printf("\t\t\t\tMATAKULIAH KONSEP PEMROGAMAN\n");
printf("-------------------------------------------------------------------------------\n");
printf("No\tNama\t\t\t\t\tNilai\t\t\tGrade\n");
printf("\tMahasiswa\t\tTugas\tUTS\tUAS\tAkhir\n");
printf("--------------------------------------------------------------------------------\n");

for(;j<i;j++){
akir=nilai_akir(n[j].tgs,n[j].uts,n[j].uas);
printf("%d\t%s\t\t\t %d\t%d\t%d\t%d\t\t%c\n",j+1,n[j].nama,n[j].tgs,n[j].uts,n[j].uas,akir,grade(akir));
}
}

Ini outputnya :)

You Might Also Like

0 komentar: