Explanation of the Book Structure Program in C
This program demonstrates the use of a structure in C to store details of books. A structure allows grouping different data types under a single name, making it easier to manage related information.
The program creates a structure named book, containing three members: name (string), price (integer), and pages (integer). It then makes an array of 3 books and takes input for each one, finally displaying the stored information.
What the Program Does
- Defines a structure book with three members.
- Creates an array b[3] to store three books.
- Uses a for loop to input name, price and pages for each book.
- Uses another for loop to display the stored values.
- Uses clrscr() and getch() which are Turbo C functions.
Example Input
Enter name, price and pages: b2 120 340
Enter name, price and pages: b3 150 450
Example Output
Summary:
This program uses a structure array to store details of multiple books.
It takes input for each book and displays the information in a clean format.
This concept is useful when handling several records with mixed data types.
