/* program 2.4 struct4.c
* menggunakan array untuk struct
*
* Dyas Yudi Priyanggodo,S.Kom
*/
#include <stdio.h>
#include <conio.h>
#define MAX 20
main() {
typedef struct {
char nama[15];
char nim[10];
char kelas[2];
int nilai;
} mahasiswa;
mahasiswa mhs[MAX];
int i, jml;
char buff[80];
printf("jumlah data: ");
gets(buff);
jml = atoi(buff);
system("cls");;
for(i = 0; i < jml; i++) {
printf("data ke: %d\n", i + 1);
printf("Nama: ");
gets(mhs[i].nama);
printf("NIM: ");
gets(mhs[i].nim);
printf("Kelas: ");
gets(mhs[i].kelas);
printf("Nilai: ");
gets(buff);
mhs[i].nilai = atoi(buff);
system("cls");;
}
printf("DATA - DATA \n-------------------\nn");
for(i = 0; i < jml; i++) {
printf("Data ke: %d\n", i + 1);
printf("Nama: %s\n", mhs[i].nama);
printf("NIM : %s\n", mhs[i].nim);
printf("Kelas : %s\n", mhs[i].kelas);
printf("Nilai : %d\n", mhs[i].nilai);
printf("-----------------\n");
}
getch();
}
Thursday, April 14, 2011
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment