-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTugas 2 struktur data week 2.cpp
81 lines (67 loc) · 2.24 KB
/
Tugas 2 struktur data week 2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#define MAX 10
struct data_mahasiswa
{
char npm [15];
char nama[50];
char jurusan[50];
char ttl[50];
char umur[3];
char kelamin[20];
char no_hp[12];
char alamat[50];
char hobby [20];
};
int main()
{
int i, jml_mhs = 0;
char tombol;
struct data_mahasiswa data_mhs[MAX];
printf ("Biodata Mahasiswa\n\n");
do //perulangan do-while
{
printf ("Masukan NPM = ");
scanf ("%s", &data_mhs[jml_mhs].npm);
printf ("Masukan Nama = ");
scanf ("%s", &data_mhs[jml_mhs].nama);
printf ("Masukan Jurusan = ");
scanf ("%s", &data_mhs[jml_mhs].jurusan);
printf ("Masukkan umur = ");
scanf ("%s", &data_mhs[jml_mhs].umur);
printf ("Masukan Tempat/ tgl. lahir = ");
scanf ("%s", &data_mhs[jml_mhs].ttl);
printf ("Masukan Jenis Kelamin = ");
scanf ("%s", &data_mhs[jml_mhs].kelamin);
printf ("Masukan No. HP = ");
scanf ("%s", &data_mhs[jml_mhs].no_hp);
printf ("Masukan Alamat = ");
scanf ("%s", &data_mhs[jml_mhs].alamat);
printf ("Masukan Hobby = ");
scanf ("%s", &data_mhs[jml_mhs].hobby);
jml_mhs++;
printf ("\nLanjut masukan data (Y/T)? : ");
tombol = toupper (getch());
while (! (tombol == 'T' || tombol == 'Y'))
tombol = toupper(getch());
printf ("%c\n\n", tombol);
}
while (tombol == 'Y');
printf ("Data Mahasiswa yang tersimpan\n");
printf ("===========================================================================\n\n");
for (i = 0; i < jml_mhs; i++)
{
printf ("Data Mahasiswa ke %d\n", i + 1);
printf ("NPM = %s\n", data_mhs[i].npm);
printf ("Nama = %s\n", data_mhs[i].nama);
printf ("Jurusan = %s\n", data_mhs[i].jurusan);
printf ("Tempat/ tgl. lahir = %s\n", data_mhs[i].ttl);
printf ("umur = %s\n", data_mhs[i].umur);
printf ("Jenis Kelamin = %s\n", data_mhs[i].kelamin);
printf ("No. HP = %s\n", data_mhs[i].no_hp);
printf ("Alamat = %s\n", data_mhs[i].alamat);
printf ("hobby = %s\n", data_mhs[i].hobby);
}
}