Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- struct mahasiswa{
- char nama[50];
- char nim[11];
- }mhs[100];
- int n=0;
- int main(){
- int menu;
- do{
- printf("1.Insert\n");
- printf("2.View\n");
- printf("3.Exit\n");
- printf(" \n");
- scanf("%d",&menu);
- fflush(stdin);
- switch(menu){
- case 1:
- printf("Insert Name : ");
- scanf("%[^\n]",&mhs.nama);
- fflush(stdin);
- printf("Insert Nim : ");
- scanf("%[^\n]",&mhs.nim);
- fflush(stdin);
- break;
- case 2:
- for(int i=0; i<n; i++){
- printf("%d. %s - %s \n", i+1, mhs.nama[i], mhs.nim[i]);
- }
- break;
- }
- }while(menu !=3);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement