Created
May 21, 2019 16:10
-
-
Save teramuza/4487c69a39cb2a48fcfd2a0c47330f46 to your computer and use it in GitHub Desktop.
E-Learning Praktikum Algoritma Pertemuan 11 (Structure) Latihan C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <cctype> | |
using namespace std; | |
struct SiswaAdapter{ | |
char Name[50]; | |
char Addr[100]; | |
char gender; | |
long int phone; | |
}; | |
int main(){ | |
SiswaAdapter dataSiswa[5]; | |
int rows = 0; char choice; | |
do{ | |
printf("Data siswa ke-%d\n", rows+1); | |
printf("Masukan Nama \t\t: "); | |
cin.getline(dataSiswa[rows].Name,80); | |
printf("Masukan Alamat \t\t: "); | |
cin.getline(dataSiswa[rows].Addr,120); | |
printf("Jenis Kelamin (L/p) \t: "); | |
cin>>dataSiswa[rows].gender; | |
printf("Masukan nomor ponsel \t: "); | |
cin>>dataSiswa[rows].phone; | |
printf("\n\nTambah data lagi? (Y/n) : "); | |
cin>>choice; | |
printf("\n"); | |
rows++; | |
}while(tolower(choice) == 'y'); | |
printf("\n-----------------Result---------------\n"); | |
for (int i = 0; i < rows; ++i){ | |
printf("Siswa ke-%d \n", i+1); | |
printf("Nama \t\t : %s \n", dataSiswa[i].Name); | |
printf("Alamat \t\t : %s \n", dataSiswa[i].Addr); | |
printf("Jenis Kelamin \t : "); | |
if(tolower(dataSiswa[i].gender) == 'l') | |
printf("Laki-laki\n"); | |
else if(tolower(dataSiswa[i].gender) == 'p') | |
printf("Perempuan\n"); | |
else | |
printf("Tidak diketahui\n"); | |
printf("Nomor Ponsel \t : %ld\n", dataSiswa[i].phone); | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment