Advertisement
albertoanggi

C - PERTEMUAN 1

Oct 9th, 2017
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. using namespace std;
  6.  
  7. void gotoxy(int x, int y)
  8. {
  9.     COORD coord;
  10.     coord.X = x;
  11.     coord.Y = y;
  12.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  13. }
  14.  
  15. int main()
  16. {
  17.  
  18. struct msh
  19. {
  20.     char npm[9];
  21.     char nama[25];
  22.     char kelas[30];
  23.     int UTS, UAS, total;
  24.    
  25. } pmhs[10];
  26.  
  27.     int i,n;
  28.    
  29.     system("cls");
  30.     printf("PROGRAM DATA MAHASISWA \n");
  31.     printf("---------------------- \n\n");
  32.     printf("Masukkan Banyaknya Data : ");
  33.     scanf("%d", &n);
  34.     printf("\n");
  35.  
  36.     for (i=0; i<n; i++)
  37.     {
  38.         printf("Input Data Mahasiswa Ke-%d\n",i+1);
  39.         printf("Nama Anda       : ");
  40.         scanf("%s", &pmhs[i].nama);
  41.         printf("NPM Anda        : ");
  42.         scanf("%s", &pmhs[i].npm);
  43.         printf("Kelas Anda      : ");
  44.         scanf("%s", &pmhs[i].kelas);
  45.         printf("Nilai UTS       : ");
  46.         scanf("%d", &pmhs[i].UTS);
  47.         printf("Nilai UAS       : ");
  48.         scanf("%d", &pmhs[i].UAS);
  49.         pmhs[i].total = (pmhs[i].UTS * 0.70) + (pmhs[i].UAS * 0.30) + 1;
  50.         printf("\n\n");
  51.     }
  52.     printf("Tekan Sembarang tombol ... !");
  53.     getch();
  54.     system("cls");
  55.     printf(" \t\t\tOutput Data Mahasiswa \n\n");
  56.     printf("=================================================================\n");
  57.     printf(" No.    Nama            NPM        Kelas      UTS   UAS    TOTAL\n");
  58.     printf("=================================================================\n");
  59.     for (i=0; i<n; i++)
  60.     {
  61.         gotoxy(2, i+6); printf("%d.",i+1);
  62.         gotoxy(7, i+6); printf("%s",pmhs[i].nama);
  63.         gotoxy(22, i+6); printf("%s",pmhs[i].npm);
  64.         gotoxy(35, i+6); printf("%s",pmhs[i].kelas);
  65.         gotoxy(46, i+6); printf("%d",pmhs[i].UTS);
  66.         gotoxy(52, i+6); printf("%d",pmhs[i].UAS);
  67.         gotoxy(60, i+6); printf("%d",pmhs[i].total);
  68.         printf("\n");
  69.     }
  70.     printf("=================================================================\n");
  71.     getch();
  72.        
  73.    
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement