PF Assignment-03 Revised
PF Assignment-03 Revised
PF Assignment-03 Revised
FALL 2023
Subject: Programming Fundamentals Total Marks: 10
Class: BS Computer Science Semester: 1st
WARNING
1. PLAGIARISM OR HIRING OF GHOST WRITER(S) FOR SOLVING THE
ASSIGNMENT(S) WILL DEBAR THE STUDENT FROM AWARD OF
DEGREE/CERTIFICATE. IF FOUND AT ANY STAGE.
2. SUBMITTING ASSIGNMENT BORROWED OR STOLEN FROM OTHER
STUDENT IS STRICTLY PROHIBITED
INSTRUCTIONS:
➢ This assignment contains a total of 10 Problem Questions.
➢ Submit the Assignment within the due date.
➢ You can get bonus marks by putting extra effort into proper documentation.
➢ To attempt this assignment, you should have full command of Lecture # 10 to Lecture 16.
➢ Try to make solutions by yourself and protect your work from other students. If we found
the solution files of some students are the same then we will reward zero marks to all
those students.
➢ Here is the recommended format to submit the assignment.
1. Mention the Problem No & Problem Statement.
3. give a heading of Code and past screen shot of the program.
4. Copy your error-free code from the compiler.
5. Paste it in your document file.
6. Then give a heading of Sample Output.
7. Execute your program & and take a screenshot of the output.
8. Crop the Dos Screen Area and Past it in document
Note:
“There are no shortcuts to success. The only way you can achieve success is to Work hard and
then pray a lot. Hard work always pays back in terms of benefits, satisfaction, experience, self-
confidence, respect and wealth. So never step back or shy to work hard and pray to be
successful.”
“It’s worth to give a sincere try to the hardest task you will ever face because completion of a
task is not in our hands, we can only work hard with sincerity and honesty and then pray to Allah
Taala because completion is in hands of Allah Almighty.”
“Always seek help in your brightest and darkest of times from Allah Taala and you will see that
He is always there for you to provide help with all of His blessings.”
I will be evaluating you by your sincere and honest efforts towards your task. Good luck!
Problem No 2: Write a program that takes a course score (a value between 0 and 100) and
determines a student’s course grade. Your program should have three functions: main,
getScore, and printGrade, as follows:
1. main
a) Get the course score.
b) Print the course grade.
2. getScore
a) Prompt the user for the input.
b) Get the input.
c) Print the course score.
3. printGrade
c) Calculate the course grade.
d) Print the course grade.
The parameter of getScore function must be pass by reference.
A. Create a function that takes input marks of five subjects as a parameter and returns
the aggregate marks of a student.
B. Create a function that takes the aggregate marks as input and print grade according
to the following table.
Aggregate Marks Grade
85-100 A
70-84 B
60-69 C
50-59 D
Less than 50 F
Problem No 4:
Pakistan cricket board contains the following records of Pakistan cricket team members,
name of the cricketer, his age, number of test matches that he has played and the average
runs that he has scored in each test match.
A. Create an array of structure to hold records of 10 cricketers
B. write a program to read these records and arrange them in ascending order by
average runs
Problem No 5: Write a program that performs flowing tasks:
a) Initialize an integer array of 10 elements in main ().
b) Create a function sort () and pass an array as a reference parameter to sort
an array using the Insertion sort algorithm.
c) Create a function print () to print array by getting array as a parameter.
Problem No 6:
In a courier company, 10 boxes of given weight are available for delivery, you are
required to write a program to perform the following operation.
Problem No 7: Imagine you are tasked with developing a program for a scientific
research team that analyzes experimental data stored in a 2D array. The team needs a
tool to efficiently input the data, print the diagonals of the matrix for a quick assessment,
and calculate the sum of all elements for further analysis.
Your assignment is to create a C program with three functions tailored for this purpose:
In your main function, demonstrate the functionality by declaring a 2D array, calling the
inputArray function to input experimental data, then using the printDiagonals function
to visually inspect diagonals, and finally, calling the sumOfElements function to obtain
the total sum.
Problem No 8: Imagine you are tasked with developing a program for a human
resources department that organizes and analyzes employee data stored in a 2D array.
Your goal is to create a C program with three functions suited for this HR application:
Problem No 9: two arrays of 10 elements are given blow, write a program to sort the
given array.
A[10]
15 18 44 64 78 95 78 55 76 12
Problem No 10: C program to perform matrix addition. Your program should take two
matrices as input, add them element-wise, and store the result in a new matrix. Follow
these guidelines to complete the program:
𝟏𝟓 𝟐𝟐 𝟐𝟎 𝟏𝟒 𝟐𝟏 𝟒𝟒
A = [𝟏𝟖 𝟏𝟎 𝟏𝟏[ B = [𝟔𝟔 𝟐𝟕 𝟑𝟐]
𝟏𝟒 𝟏𝟐 𝟑𝟑 𝟖𝟏 𝟐𝟑 𝟏𝟏