All arrays must be created dynamically. Mentioned above file may contain any number of records.
Use three arrays: a one-dimensional array to store the students’ names, a (parallel) two-dimensional array
to store the test scores, and a parallel one-dimensional array to store grades. Your program must contain
at least the following functions: a function to read and store data into two arrays, a function to calculate
the average test score and grade, and a function to output the results. Have your program also output the
class average.
Problem – 2 (Library Summary)
Create a library fine summary program. You will read a file of library patron data containing a library
patron number, an item (book, movie, music) number, and a fine amount. At most, there will be five
library patrons in the file. You will produce a summary report that lists the total fines for all of the patrons
in the input file.
Input File
BK 502 10
MC 102 5
MV 189 7
NS 208 2
CS103 – Computer Programming (A&C) Deadline: February 16, 2014
, Assignment # 2 (Pointers & DMA)
AR 189 51
MC 122 5
NS 218 32
MC 502 23
MV 189 20
MC 102 5
BK 248 10
MC 162 80
… … …
… … …
… … …
… … …
… … …
Output file:
BK <Fine Sub Total of all BK Patrons>
MC <Fine Sub Total of all MC Patrons>
MV <Fine Sub Total of all MV Patrons>
AR <Fine Sub Total of all AR Patrons>
NS <Fine Sub Total of all NS Patrons>
--------------------------------------------
Total <Total of All patrons>
Problem – 3 (Local Elections)
Write a program that reads the names of candidates in a local election and the number of votes received
by each candidate from a file. The program should then output each candidate’s name, the number of
votes received, and the percentage of the total votes received by the candidate.
[Hint: Use Dynamic Array only. Create one array to store names, a 2D array to store votes and calculated
percentage. All functions with pointer/pointer arrays]
Your program should also output the winner of the election. A sample output is:
Candidate Votes Received % of Total Votes
Waleed Azhar 5000 25.91
Tamur Fazal 4000 20.73
Hamza Abbas 6000 31.09
Tayyab Rehman 2500 12.95
Waqas Ahmed 1800 9.33
---------------------------------------------------------
Total 19300
---------------------------------------------------------
The Winner of the Election is Hamza Abbas.
CS103 – Computer Programming (A&C) Deadline: February 16, 2014
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller eston. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $7.49. You're not tied to anything after your purchase.