Please be sure to write the code in C language and using an
Please be sure to write the code in C language and using an int main()
Problem: Silent Auction Fundraiser (auction.c)
 Programmers for a Better Tomorrow is hosting a silent auction to benefit one of their main charities. Participants in a silent auction write down which item they are bidding for and how much they are willing to bid.
This program will read from a file that contains a list of bids on a number of auctions. The program must determine the amount that each item will be sold for. This will be the highest amount that someone is willing to bid on that item.
When the final bid amount for each item has been determined, print this information to the screen.
Finally, calculate the total amount of money made for the auction (the sum of the final bids of each item) and print this information to the screen.
Arrays are not required (except for the name of the input file), but may simplify your solution.
Input Specification
 The file name will be a string less than 30 characters in length. There will be no other input from the user.
Input File Specification
 The first line of the file will contain a single positive integer, n (n <= 10), representing the number of items up for auction. Information about each auction follows.
The first line of each auction will contain a single positive integer, k, representing the number of bids on that item. Following this value there will be k integers, in any order, that represent the individual bids on that item in dollars.
Output Specification
 Output to the screen. For each auction, print the following:
Auction #A was sold for $X.XX!
where A is the number of the auction and X is the highest bid for that auction.
At the end of the program, print the total amount of money the auction raised:
The silent auction raised $Y.YY for charity!
Sample Run
 Below is a sample output of running the program. Note that this sample is NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above.
In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for clarity’s sake.)
Sample Input (input.txt)
 5
 4
 100 500 250 300
 1
 700
 3
 300 150 175
 2
 920 680
 8
 20 10 15 25 50 30 19 23
Sample Output
 Please enter the name of the file.
 input.txt
Auction 1 was sold for $500.00!
 Auction 2 was sold for $700.00!
 Auction 3 was sold for $300.00!
 Auction 4 was sold for $920.00!
 Auction 5 was sold for $50.00!
The silent auction raised $2470.00 for charity!
Deliverables
 One source file – auction.c – is to be submitted over WebCourses.
Restrictions
 Although you may use other compilers, your program must compile and run using Code::Blocks. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include comments throughout your code describing the major steps in solving the problem.
Grading Details
 Your programs will be graded upon the following criteria:
1) Your correctness
2) Your programming style and use of white space. Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor, you could get 10% or 15% deducted from your grade.
3) Compatibility – You must submit C source files that can be compiled and executed in a standard C Development Environment. If your program does not compile, you will get a sizable deduction from your grade.
sample input file-
5
 4
 100 500 250 300
 1
 700
 3
 300 150 175
 2
 920 680
 8
 20 10 15 25 50 30 19 23
Solution
/*************auction.c************/
#include <stdio.h>
int main(int argc, char *argv[] )
 {
     /*variable declaration*/
     char stringLine[10][50];
     /*if file input is not given*/
     if(argc!=2)
     {
         printf(\"Please Enter file name \ \");
         return 1;
    }
     else
     {
        // We assume argv[1] is a filename to open
         FILE *file = fopen( argv[1], \"r\" );
        /* fopen returns 0, the NULL pointer, on failure */
         if ( file == 0 )
         {
             printf( \"Could not open file\ \" );
         }
         else
         {
             /*Variable declarations*/
             int number = 0;
             int totalValues=0;
             int toatlAuctionvalue=0;
             int price=0;
             int maxAuction=0;
             int auctionCount=1;
             /*Reading total auctions*/
             fscanf(file, \"%d\", &number);
             /*Reading line by line from file*/
             while (number>0)
             {
                 /*Reading number of bids*/
                 fscanf(file, \"%d\", &totalValues);
                 /*while loop for reading auction values*/
                 while(totalValues>0)
                 {
                     /*Reading auction values*/
                     fscanf(file, \"%d\", &price);
                     /*checking maximum auction value*/
                     if(price>maxAuction)
                     {
                         maxAuction=price;
                     }
                     totalValues--;
}
                 /*Calculating Total Auction value*/
                 toatlAuctionvalue+=maxAuction;
                 printf(\"Auction %d was sold for $%.2f! \ \",auctionCount,(float)maxAuction);
                 maxAuction=0;//setting maxAuction to 0 for next use
                 auctionCount++;
                 number--;
             }
             /*Printing Total Auction Values*/
             printf(\"The silent auction raised $%.2f for charity! \ \",(float)toatlAuctionvalue);
             /*Closing file*/
             fclose( file );
        }
     }
     /*Returning to OS*/
     return 0;
 }
 /*Main function end*/
 /************output start***********/
raj@raj:~/Desktop/chegg$ gcc auction.c
 raj@raj:~/Desktop/chegg$ ./a.out test.txt
 Auction 1 was sold for $500.00!
 Auction 2 was sold for $700.00!
 Auction 3 was sold for $300.00!
 Auction 4 was sold for $920.00!
 Auction 5 was sold for $50.00!
 The silent auction raised $2470.00 for charity!
/**************output End**********/
/**************file input***********/
5
 4
 100 500 250 300
 1
 700
 3
 300 150 175
 2
 920 680
 8
 20 10 15 25 50 30 19 23
/***********File input End***************/
If you have any query please feel free to ask
Thanks a lot




