Senin, 28 Maret 2011

Listing Program Data Mahasiswa


Nama file : nilairya.C

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

void main()
{
struct mhs
{
      char npm[9];
      char nama[25];
      int nilai,total,rata2;
}
pmhs[10];
      int i,j,r,a,rna,rke;
      clrscr();
      printf("           ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ        \n");
      printf("           º  PROGRAM DATA MAHASISWA  º\n");
      printf("           ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ      \n\n");
      printf("Masukkan Jumlah Mahasiswa : ");
      scanf("%d",&r);
      printf("\n");
      printf("Masukkan Banyak Nilai yang Diinput: ");
      scanf("%d",&a);
      printf("\n");
      for (i=0; i<r; i++)
      {
            clrscr();
            printf("Input Data Mahasiswa Ke-%d\n",i+1);
            printf("* Gunakan underscore sebagai ganti spasi\n\n");
            printf("Nama Anda       : ");
            scanf("%s", &pmhs[i].nama);
            printf("NPM Anda        : ");
            scanf("%s", &pmhs[i].npm);
            printf("\n\n");
            pmhs[i].total=0;
                  for (j=0; j<a; j++)
                  {
                  printf("Input Nilai Ke-%d\n",j+1);
                  scanf("%d", &pmhs[j].nilai);
                  pmhs[i].total=pmhs[i].total+pmhs[j].nilai;
                  pmhs[i].rata2=pmhs[i].total/a;
                  }
      }          
      printf("Press any key to continue ... !");
      getch();
      clrscr();
      printf("                   >>> Output Data Mahasiswa <<< \n\n");
      printf("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ \n");
      printf("º No.   Nama      NPM           Nilai Total    Rata-Rata º\n");
      printf("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ \n");
for (i=0; i<r; i++)
      {
            gotoxy(4, i+6);printf("%d.",i+1);
            gotoxy(9, i+6);printf("%s", pmhs[i].nama);
            gotoxy(17, i+6);printf("%s", pmhs[i].npm);
            gotoxy(38, i+6);printf("%d\n", pmhs[i].total);
            pmhs[i].rata2=pmhs[i].total/a;
            gotoxy(53, i+6);printf("%d\n", pmhs[i].rata2);
      }
      printf("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ \n");
      getch();
rna=0;
for (i=0; i<r; i++)
      {
      rna=rna+pmhs[i].rata2;
      }
      rke=rna/r;
      gotoxy(10, 15);printf("rata2 kelas = %d\n", rke);
      getch();
}

Tidak ada komentar:

Posting Komentar