PF FINAL PAPER___
PF FINAL PAPER___
PF FINAL PAPER___
Instructions:
● The Final Exam consists of eight questions. Be sure that you have all of these and that they are all legible.
● Read all questions and their instructions thoroughly before you begin. It is always worth your time to plan
ahead!
● Write your roll number, section accompanied by your signature on each page.
● The Final Exam is worth 50 weightage.
● Points will be awarded based on your explicit answers. Partial credit will be given where possible, so show
all of your work.
● Read the question properly, you can’t find it on google so “don’t waste your time”. It’s easy.
● You are supposed to make a program according to the question.
● Don’t share your work, if your submission is matched to any member of your class, both will be marked 0
straight without asking who shared or who magically copied.
● You have to “ATTEMPT ON Paper”.
● In case of non availability of internet due to load shedding etc, mobile data should be good enough to
download and upload files. You do not need the internet during 3 hour offline exams. So better, fully charge
your mobile battery and ready to upload data using mobile in case of emergency.
● 180 minutes is for an exam to attempt, 30 minutes for pdf formation and submission on LMS (Slate/
Google Classroom). If you find some problem with LMS, don’t waste your time and email your theory
teacher with the subject: FINAL_DS_SectionName. Also submit the same later to LMS as well.
● Email Addresses are: farah.sadia@nu.edu.pk || tania.iram@nu.edu.pk || atiya.jokhio@nu.edu.pk
● Submissions after 12:30 pm are considered late. There is a penalty for late submission i.e deduction of 5
points for 10 minutes late submission.
Time: 180 minutes (to attempt) + 30 minutes (to submit) Max weightage: 50
The program first asks to enter the no of categories of bakery items i.e. 1 or 2, then it asks to enter the
choice i.e. ‘C’ for Cake, ‘B’ for Biscuits and then for quantity. If the customer asks for other than menu
items, it shows a message of the unavailability of items on bakers. The program should finally display the
total charges for the order. Example input/output data is given:
A SuperMarket wants to maintain the record of customer visits, items available and quantity of items.
Suppose you are a software designer of that software house and you are assigned to do this task using
structure and filing. Following are the requirements of the supermarket’s owner :
a) The worker has to maintain the record of ‘n’ customers in (customer_details.txt) file.
b) Customer details include: a customer ID (type int), a customer Name (type string), Customer
address (consisting of street address, city, state). Hint: Structure nesting is required in address
field. [ The user has to input all the data].
c) The worker has to maintain the ID of Product, Name of Product, Quantity of Product in
(Product_details.txt) file. He should take the input from the user until the user enters ‘EOF’.
Further, the worker should have menu to select any option out of the given three below:
i) list out all the maintained items.
ii) list only those items whose quantity is zero.
iii) list only those items whose quantity is greater than fifty.
During Covid-19 spread, civil hospital has to manage budget for its 6 departments. Its account manager
has to track expense report : department-wise and month-wise from January to May in the following
format:
Expense report
===================================================================================
Department
----------------
Write a program using 2-dimensional arrays to hold the expense month-wise and department-wise.
a. Department and Months names should be stored and displayed using array of string pointers.
b. Modular programming should be used i.e. input-data(parameters list..),output data(parameters
list…), department-wise-total(parameters list…),month-wise-total(parameters list…) should be
used to generate report.
c. 2D array holding expenses should be passed from main to all functions by reference.
d. Calculate and display based on data, which department will need federal support i.e. expenses
higher than 50,000.
e. Display which month was stable in terms of expenses i.e having the lowest monthly expense
Consider: Two trains are on the same track and they are coming toward each other. The speed of the
first train is 50 km/h and the speed of the second train is 70 km/h. A honeybee starts flying between the
trains when the distance between two trains is 100 km. The honeybee first flies from first train to
second train. Once it reaches the second train, it immediately flies back to the first train … and so on
until trains collide. Calculate the total distance travelled by the honeybee. Speed of a honeybee is 80
km/h. Distance formula is given below.
Total distance travelled by honeybee:
(honeybee speed * distance)/(train_1 speed + train_2 speed)
Game Rules:
If player A chooses box "1" and opens it then, Player B can not have the opportunity to open box "1".
Once the box is opened that is no longer available to open again.
For each box make sure to allocate the memory dynamically in the main() and initialize cash of each box
randomly by using rand(), pass to the user defined function "Jeet_ki_bazi()" play the complete game
turn by turn in this function and calculate sum of each player's cash . Return the both player cash values
to the main function without using any array or static variable. Use the two individual variables for total
cash of each player. After returning to main() use the ternary operator to make a decision which player
won the game and display the player name with "Congratulations on your well-deserved success".
For example the number of boxes are 6 and are placed in front of you on a table. At the end sum the all
cash of each player. The player that collects maximum cash with more value wins the game.
Initial row: 28 22 10 33 19 40
Round # Process
Round 1: Player A picks box 1: which has 28 rupees, now remaining boxes of cash is
After first pick: 22 10 33 19 40
Player B picks box 4: which has 33 rupees, now remaining boxes of cash is
Total: The total value collected by Player B is more (33 + 22 + 19) compared to the first player (22 + 40 + 10).
So the second picker, Player B wins. Congratulations on your well-deserved success.
Hint: you may use string.h functions for string comparing and tokenizing
Sorted: Name:{”Hina”,“Ali”,”Zain”,”Hashim”,”Sara”,”Bakhtawar”,”Zeeshan”,”Jameela”,”Asfa”,”Zahid”}
Covid:{“P”,”P”,”P”,”P”,”N”,”N”,”,”N”,”N”,”N”,”N”}