Create a structure Book with entities - book name, author name, page, price.
Input data for 10 books. Print the detail of the book with the highest page number.
#include <stdio.h>#include <conio.h>#include <string.h>/*Structure define*/struct bookList{char bookName[20];char authorName[20];int page;float price;};int main(){int number, i, j, max = 0;A1:printf("\nEnter Number Of Books : ");scanf("%d", &number);if (number < 2){printf("!!! Enter Minimum 2 Number !!!");goto A1;}struct bookList book[number];for (i = 0; i < number; i++){printf("\nEnter book name : ");scanf("%s", &book[i].bookName);printf("Auther Name : ");scanf("%s", &book[i].authorName);printf("Pages In The Book : ");scanf("%d", &book[i].page);printf("Price Of The Book : ");scanf("%f", &book[i].price);}for (i = 0; i < number; i++){if (book[i].page > book[max].page){max = i;}}printf("\n%s - book has maximum number of page %d . Written by %s And the price is %.0f", book[max].bookName, book[max].page, book[max].authorName, book[max].price);return 0;}
Output:
0 comments:
Post a Comment