Tak ada kata sempurna untuk dunia IT

29 Okt 2010

Contoh Program Struct Buku Perpustakaan Dalam C++

#include
#include
void main ()
{
struct book
{
int book_code;
char book_name[25];
int year_published;
char author[25];
int price;
};
book n;
int x, c;

cout<<"======================"<
cout<<"TASK PRACTICUM - THE ALGORITHM AND PROGRAMMING 2"<
cout<<"                                             Data Structure                                                  "<
cout<<"====================="<

cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<
cout<<" Name : Istakhori     "<
cout<<"  NPM : 065108151  "<
cout<<" Class : F     "<

cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<

cout<<" How many times have your data entry? ";
cin>>c;
cout<

for (x=1; x<=c; x++)
     {
     cout<<"   Data of- :     "<<
     cout<<"    What is the code of book?  ";
     cin>>n.book_code;
cout<<" What is the name of the book? (space use _ ) ";
     cin>>n.book_name;
     cout<<" What year was published?";
     cin>>n.year_publishedt;
     cout<<" Who's the author?   (space use _ );
     cin>>n.author;
     cout<<" What is the price?";
     cin>>n.price;
     cout<<"================="<
}
cout<
cout<<"  The data has been entered is :  "<
cout<
for (x=1; x<=c; x++)
{
                  cout<<"   Data of- :     "<<
                  cout<<"  Code of book :    ";
                  cout<<
                  cout<<"  Name of book  :   ";
                  cout<<
                  cout<<" Year Published :  ";
                  cout<<
                  cout<<"   Author  :     ";
                  cout<<
                  cout<<"  Price  :     ";
                  cout<<
cout<<"======================="<
}
getch();
}

Tidak ada komentar:

Poskan Komentar