mardi 27 novembre 2018

if statement in struct c ++

hello I have a simple program but this has a few problems in the status variable, how do I fix it?

#include <iostream>

using namespace std;

int main (){

struct Nasabah
{
    char namaLengkap[50];
    char alamatrumah[100];
    char noHP[13];
    int status;
    int kode;

}nsbh;

cout<< "Kode: ";
cin>>nsbh.kode;
cout<< "\nNama Lengkap: ";
cin>>nsbh.namaLengkap;
cout<< "Alamat Rumah: ";
cin>>nsbh.alamatrumah;
cout<< "No HP: ";
cin>>nsbh.noHP;
cout << "Status: ";
cin>> nsbh.status;
    if(nsbh.status == 1)
    {
    cout<"Aktif";
    }
    else if(nsbh.status == 0)
    {
    cout<<"Tidak Aktif";
    }
cout << "\nDATA NASABAH\n";
cout << "Kode           :   "<<nsbh.kode<<endl;
cout << "Nama Lengkap       :   "<<nsbh.namaLengkap<<endl;
cout << "Alamat Rumah       :   "<<nsbh.alamatrumah<<endl;
cout << "NO HP          :   "<<nsbh.noHP<<endl;
cout << "Status         :   "<<nsbh.status<<endl;


return 0;
}

want to ouput status is "aktif" or "tidak aktif"

Aucun commentaire:

Enregistrer un commentaire