Menu

Custom Search

C++ lab Program bank

#include
#include
static union
{
int yens;
float dollars;
};

struct book
{
private:
char title[30];
char author[30];
char code;

public:
void getdata();
void display();
} ;
void main()
{
clrscr();
book b;

b.getdata();
b.display();
getch();
}
void book::getdata()
{
cout<<"Enter title of book:"< cin>>title;
cout<<"Enter author name:"< cin>>author;
cout<<"Enter code(j/J for Japanese and a/A for American):"< cin>>code;
if(code=='j'||code=='J')
{ cout<<"Enter price in yen:"< cin>>yens;
}
if(code=='a'||code=='A')
{ cout<<"Enter price in dollar:"< cin>>dollars;
}
}
void book::display()
{
cout<<"Title:"< cout<<"Author:"< if(code=='j'||code=='J')
cout<<"Price Y"< if(code=='a'||code=='A')
cout<<"Price:$"<

}

No comments:

Post a Comment