Program to illustrate use of structure


#include<iostream.h>
#include<conio.h>
void main()
{
    struct book
    {
        char name;
        float price;
        int pages;
    };
    struct book b1,b2,b3;
    cout<<"\nEnter names,prices & no of pages of 3 books";
    cin>>b1.name>>b1.price>>b1.pages;
    cin>>b2.name>>b2.price>>b2.pages;
    cin>>b3.name>>b3.price>>b3.pages;
    cout<<"\nAnd this is what you entered";
    cout<<"\n"<<b1.name<<"\t"<<b1.price<<"\t"<<b1.pages;
    cout<<"\n"<<b2.name<<"\t"<<b2.price<<"\t"<<b2.pages;
    cout<<"\n"<<b3.name<<"\t"<<b3.price<<"\t"<<b3.pages;
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|