structures c++


#include<iostream>
using namespace std;
#include<string>

#include<iomanip>//included for using setw(10) function
int main(){

struct abc{//structure template
string author;
string book;
float price;
};
  
struct abc libry[5]; // declare libry variable that will contain 5 records
int count=0;
while(count<5){

cout<<"book's name = ";
cin>>libry[count].book;
cout<<endl<<" authors name = ";
cin>>libry[count].author;
cout<<endl<<endl<<" price = ";
cin>>libry[count].price;

cout<<endl<<endl;
count++;
}

cout<<"now printing whole se "<<endl;
cout<<"book no"<<setw(10)<<"book name "<<setw(10)<<"author"<<setw(10)<<"price"<<endl<<endl;

for(int x=0;x<5;x++){
cout<<x<<setw(10)<<libry[x].book<<setw(10)<<libry[x].author<<setw(10)<<libry[x].price<<endl;


}
}











Previous
Next Post »

Comments:

Disqus Shortname