#include <stdio.h>
// Define the struct
struct Book {
char title[50];
float price;
};
// Function to print book details
void printBook(struct Book b) {
printf("Title: %s\n", b.title);
printf("Price: %.2f\n", b.price);
}
int main() {
struct Book book1, book2;
// Input for first book
printf("Enter title of first book: ");
scanf("%49s", book1.title); // %49s prevents buffer overflow
printf("Enter price of first book: ");
scanf("%f", &book1.price);
// Input for second book
printf("Enter title of second book: ");
scanf("%49s", book2.title);
printf("Enter price of second book: ");
scanf("%f", &book2.price);
// Print both books
printf("\n--- Book Details ---\n");
printBook(book1);
printf("\n");
printBook(book2);
return 0;
}