Write a program using structure to define the elements of a book entity and to display the same.
/* Code for defining a structure and to display using structure */
#include"iostream.h"
#include"string.h"
struct book
{
int bookno;
char bookname[30];
char author[25];
float price;
};
void main()
{
book mybook;
mybook.bookno = 100;
strcpy(mybook.bookname,"Introduction to C++");
strcpy(mybook.author,"Surya");
mybook.price = 150.00;
cout << "The book number is " << mybook.bookno;
cout << "The book name is " << mybook.bookname;
cout << "The author of the book is " << mybook.author;
cout << "The price of the book is " << mybook.price;
}
No comments:
Post a Comment