Bsee21036 Assignment 03
Bsee21036 Assignment 03
Submission:
• Email instructor if there are any questions. You cannot look at others’ solution or use others’
solution, however, you can discuss it with each other. Plagiarism will lead to a straight zero
with additional consequences as well.
• Submission after due time will not be accepted.
• Make a menu driven program (compulsory). Declare in function.h. Define functions in
function.cpp. Call these functions from main.cpp file using menu driven approach.(else if or
switch case). Create function.h, function.cpp, and main.cpp files by your self.
Task 1
University wants you to write a program that can generate seating arrangement of exam, so you
need to take as an input from them number of rows and columns where the students need to be
seated.
Hint : Create an M x N 2-Dimensional array of students using DMA.
Students information available are roll number, name and CNIC number
The program should, then, perform the following operations:
• Write a function to take the information of students from the user, based on number of
students.
• Write a function to take input from user for the number of rows and columns available in
the room
• Handle all boundary cases for capacity versus seating requirement
• Write a function to sort the students in decreasing order based on their roll number in
columns.
• Write a function to print all elements, separated by a “ - “ for with in a row and next row
should come in next line.
• Write a function to sort the students in alphabetical order based on their names in
columns.
Task 2
Recursive functions are the functions which are calling the same function in the definition of the
body in at least one possible flow. There is a supplier of water, who has containers of m liters and
you have containers of n liters. Write a program through a recursive function that will take in m
and n from the user and determine how many minimum m liters containers he can bring in
supply so you can collect through x number of n liters tanks. You cannot use partially filled
containers or return them either.
Task 3
Sets: The collection of well-defined distinct objects is known as a set. The word well-defined
refers to a specific property which makes it easy to identify whether the given object belongs to
the set or not. The word ‘distinct’ means that the objects of a set must be all different.
Sets and arrays have several features in common. They both store a collection of values of the
same type. A set is unordered and each element can only appear once in a set. While an array can
contain duplicate elements, each value contained in a set is unique.
Example: arr below is an array which does not ensure that data is not duplicated
therefore it is not a set, while arr2 is a set.
cout << endl;// displaying the output and moving to next line
}
}
void sortStudentsByRoll(Student* students, int numRows, int numCols) {// declaring function
int totalStudents = numRows * numCols;
sort(students, students + totalStudents,
[](const Student& x, const Student& y) {
return x.Rollnumber > y.Rollnumber;// returning
});
}
void SeatingArrangement(const Student* students, int numRows, int numCols) {// declaring the
function
int totalStudents = numRows * numCols;
cout << "Enter the number of rows: ";// displaying the output
cin >> numRows;// input from user
cout << "Enter the number of columns: ";// displaying the output
cin >> numCols;// input from user
Student* students;
getStudentInformation(&students, numRows, numCols);
// task02
#include <iostream>// preproccessar
using namespace std;// cout library