0% found this document useful (0 votes)
26 views4 pages

2023 Fall PF Assignment 3 v2.0

The document provides instructions for Assignment #3 for the Programming Fundamentals course. It consists of 4 questions related to programming in C. Question 1 involves writing a program to process matrices of different dimensions and extract maximum values. Question 2 deals with modeling employee data using structures and finding the best department. Question 3 requires merging data from different text files. Question 4 tasks writing a program to display maximum salary details for each department and fetch total salaries paid to each department. Students are advised to avoid plagiarism which will result in a zero grade.

Uploaded by

abuzarali1124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

2023 Fall PF Assignment 3 v2.0

The document provides instructions for Assignment #3 for the Programming Fundamentals course. It consists of 4 questions related to programming in C. Question 1 involves writing a program to process matrices of different dimensions and extract maximum values. Question 2 deals with modeling employee data using structures and finding the best department. Question 3 requires merging data from different text files. Question 4 tasks writing a program to display maximum salary details for each department and fetch total salaries paid to each department. Students are advised to avoid plagiarism which will result in a zero grade.

Uploaded by

abuzarali1124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

National University of Computer & Emerging Sciences, Karachi

Fall 2023 (School of Computing)


Assignment # 3

Course Code: CS-1002 Course Name: Programming Fundamentals


Course Instructors: Mr. Muhammad Shahzad, Dr. Farooque Hassan Kumbhar, Dr. Abdul Aziz, Mr.
Syed Zain Ul Hassan, Mr. Basit Ali, Ms. Sobia Iftikhar
Open Date: Nov 25, 2023 Deadline: Dec 05, 2023, 11:59 PM
Important instructions:

● You must never share your assignment with anyone. If any part of your assignment is found to be
copied, then you will be awarded 0 marks as per the university policy.
● The assignment must be submitted before the deadline.
● Carefully read the submission instructions given below.

Submission:

▪ Each student should submit these files:


o A zip of all source files named as "A2-Q#-[StudentID]" where # is the question
number and Student ID is your ID, example A2-Q1-23k1234.c
o A DOC file where they copy code for each question and screen shot of the output.
This document contains all the questions, answer codes and output in sequence.
Name this document as “A2-[StudentID].docx”.
o All the submissions will be made on Google Classroom.
▪ Each output should have STUDENT ID and NAME of the student at the top.
▪ Random student will be called for VIVA from the submitted assignment and any cheating
will be penalized by zero grades.
▪ It should be clear that your assignment would not get any credit if the assignment is
submitted after the due date.
▪ Zero grade for plagiarism (copy/ cheating) and late submissions.

Question 1: [20 points]


Write a C program that takes a matrix from the user as input. The dimensions can be (2x2, 4x4,
and 8x8). Make sure that your program tackles any of the dimensions. Your program should
compute the max value from each 2 x 2 submatrix and save it into a new matrix.

For instance, for a 2 x 2 input matrix resultant matrix would have dimensions 1 x 1, for a 4 x 4
input matrix resultant matrix would have dimensions 2 x 2, and for 8 x 8 input matrix resultant
matrix have dimensions 4 x 4. Please refer to the following image to review the working of the
program.

The following matrix has four submatrices of 2 x 2 dimensions, and their maximum values are
saved into a new matrix having dimensions 2 x 2. For example, each submatrix's subscripts and
max values are provided in the example below.
max(A[0][0],A[0][1],A[1][0],A[1][1]) = 5, max(A[0][2], A[0][3], A[1][2], A[1][3]) = 3
max(A[2][0], A[2][1], A[3][0], A[3][1]) = 7, max(A[2][2], A[2][3], A[3][2], A[3][3]) = 4
A) Your solution must have the required functions for matrix processing. For 2x2, for 4x4 and for 8x8,
equal points are allocated. [15 points]
B) Main function that operates and performs operation on the functions. Use your student id as input
to the functions. E.g., 23k-1234 then your input array should have your id of 1234 repeatedly. [5
points]

Make sure that your student ID and Name is visible in every output. Plagiarism will result in a direct 0
grade in the assignment.

Question 2: [10+10 points]


Pioneers Limited corporation has 4 departments: HR, Finance, Marketing, Logistics. Each
department consists of 5 employee’s roles/ positions with the following attributes: Name, Role,
Communication, Teamwork, Creativity. The values for communication, teamwork, and creativity
should be between 1 and 100 (inclusive).

Your program must use structures to implement the following:

A) For each of the 4 departments, initialize the attributes of their employees randomly using
the rand () function.
a. Create an initial pool of 20 names from which the names will be randomly assigned
to each employee. A name cannot be repeated twice. If your names are same as
any other student, then you will be awarded 0 marks.
b. Each department will have exactly the following roles: Director, Executive,
Manager, Employee, Trainee. A role cannot be repeated twice in the same
department. The values for communication, teamwork, and creativity should be
between 1 and 100 (inclusive), also randomly assigned.
B) The retail company wants to give an award for “Best Department”. To find this out, you
must compute the sum of values of each employee for all the departments. Then compare
these 4 sums with each other to find out the best department. Your program should
output the sum for each department along with the winner of the award of “Best
Department”. You must print the Best Department details in the tabular form with all
employees and their attributes.
Question 3: [10 points]
Create three text files named Department.txt, Personal.txt and Combine.txt. The Personal.txt file contains
ID and Name. Whereas the Department.txt file contains ID and Salary. Write a function that takes input
as record IDs and merges the details from both personal and department files and then add this entry into
the Combine.txt file (ID, Name, Salary).

Personal.txt Department.txt
ID Name ID Salary

101 Zeeshan 103 50000

102 Shiraz 101 45000

103 Bilal 102 55000

Combine.txt
ID Name Salary

101 Zeeshan 45000

102 Shiraz 55000

103 Bilal 50000

Question 4: [10+10 points]


Let's suppose you have the following three 2D arrays named Worker, Bonus, and Tile with the given data.
There is one common column i.e. Worker_ID in all these arrays.

Worker:
Bonus: Title:

TASK: Write a ‘C' program for each of the following tasks:

a. Display the details of the workers having a maximum salary for each department.

Sample Output:
003 Vishal Singhal 300000 2014-02-20 HR
004 Amitabh Singh 500000 2014-02-20 Admin
006 Vipul Diwan 200000 2014-06-11 Account

b. Fetch departments along with the total salaries paid for each of them. e.g.
Sample Output:
HR - 400000
Admin - 1170000
Account - 275000

***********************END OF THE ASSIGNMENT***********************

You might also like