TUGAS program data mahasiswa C++ pakai typedef struct


#include <cstdlib>
#include <iostream>

typedef struct { char nama [100];
                 char jur [100];
                  char  nim [100];
                  int nilai;
                  } data;

data b;
using namespace std;

int main(int argc, char *argv[])
{
    cout<<" ======================================== "<<endl;
    cout<<"        PROGRAM UNTUK MENCATAT DATA "<<endl;
    cout<<"              MAHASISWA"<<endl;
    cout<<" ======================================== "<<endl<<endl;
    cout<<" \n MASUKKAN NAMA    ANDA  ";cin>>b.nama;
    cout<<" \n MASUKKAN NIM     ANDA  ";cin>>b.nim;
    cout<<" \n MASUKKAN NILAI   ANDA  ";cin>>b.nilai;
    cout<<" \n MASUKKAN JURUSAN ANDA  ";cin>>b.jur;
    cout<<" ======================================== "<<endl<<endl;
    cout<<"               TERIMAKASIH        "<<endl;
    cout<<" ======================================== "<<endl<<endl;
 
    b.nama;
    b.nilai;
    b.jur;
    b.nim;
 
    cout<<" \n NAMA    ANDA "<<b.nama<<endl;
    cout<<" \n NIM     ANDA "<<b.nim<<endl;
    cout<<" \n JURUSAN ANDA "<<b.jur<<endl;
    cout<<" \n NILAI   ANDA "<<b.nilai<<endl;
 
 
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hasil dari program di atas, seperti gambar di bawah ini :


Komentar

Posting Komentar

Postingan Populer