Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <stdlib.h>
- struct Bfair {
- char BookName[100];
- char AuthorName[100];
- int CopiesSold;
- };
- void BestSeller(struct Bfair arr[],int n) {
- FILE *fp;
- fp = fopen("bestbook.txt", "w");
- int mx=0,i;
- for(i=0;i<n;i++) {
- if(arr[i].CopiesSold>mx) mx=arr[i].CopiesSold;
- }
- for(i=0;i<n;i++) {
- if(arr[i].CopiesSold==mx){
- fprintf(fp,"BookName: ");
- fprintf(fp,"%s\n",arr[i].BookName);
- fprintf(fp,"AuthorName: ");
- fprintf(fp,"%s\n",arr[i].AuthorName);
- fprintf(fp,"CopiesSold: %d\n\n",arr[i].CopiesSold);
- }
- }
- }
- int main() {
- struct Bfair vr[200];
- int i=0;
- for(i=0;i<200;i++) {
- printf("Enter the Book name: ");
- gets(vr[i].BookName);
- printf("Enter the Book's Author name: ");
- gets(vr[i].AuthorName);
- printf("Enter the Book's sold copy number: ");
- scanf("%d",&vr[i].CopiesSold);
- getchar();
- }
- BestSeller(vr,200);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement