Menu

Custom Search

C++ lab Program

#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:"<>title;
cout<<"Enter author name:"<>author;
cout<<"Enter code(j/J for Japanese and a/A for American):"<>code;
if(code=='j'||code=='J')
{ cout<<"Enter price in yen:"<>yens;
}
if(code=='a'||code=='A')
{ cout<<"Enter price in dollar:"<>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