CS100 Computational Problem Solving: Fall 2021-22 Deadline
CS100 Computational Problem Solving: Fall 2021-22 Deadline
Fall 2021-22
functions
Lab Guidelines
1. You must put all your work into a folder named PreLab11_YourRollNo (e.g,
PreLab11_22100063), compress it into a “zip” file and submit the zip file on
LMS(Assignment -> PreLab11) before 10:55AM, Monday 22nd November. .
No late submissions or email submissions will be accepted.
2. Communicating with each other is NOT permitted. Searching for answers or help on
the internet is not permitted. All help material provided in the Lab Manual is allowed.
If you have a question, ask the TAs on Slack in your lab section channel.
3. The object is not simply to get the job done, but to get it done in the way that is asked
for in the lab. The objective is not just to get the code working, but to have a deep
understanding of why it is working. The viva will judge you on that.
4. Any cheating case will be reported to the Disciplinary Committee without any delay.
5. Failure to adhere to the naming convention of the file will result in 2.5 marks deduction.
6. Failure to adhere to coding conventions of the file will also result in 2.5 marks
deduction.
Coding Conventions:
● Constants are “ALLCAPS” or “ALL_CAPS”.
● Variables are “allsmall” or “all_small”.
All function names must be “firstWordSmallAllOtherWordsCamelCase”.
● All curly brackets defining a block must be vertically aligned.
● File naming: PreLab11_YourRollNo
Learning Objective:
Learn the use of 2D arrays in C++
Learn how to pass 2D arrays to functions
Task 1: [ 12.5marks]
In this question, you will be making a login-signup system for students. This system will utilize a 2D
array of dimensions 10 x 2.
When the program begins, you will ask the student whether he wants to Log in or Sign up.
If sign up is chosen:
The program should prompt the student for their Username, and take it’s input.
The program should then, prompt the student for their password, and take it’s input.
Error check: If the 2D array is full, the program should notify the user that it has reached the
maximum number of allowed users.
If the maximum number of users have not been reached, the program should store the User’s
username and password inside a new row.
If log in is chosen:
The program should prompt the student for their Username, and take it’s input.
The program should then, prompt the student for their password, and take it’s input.
The program will then output “You are logged in” if the username and password that the user entered
exist inside the 2D array (meaning this user has an existing account, and has now entered the correct
credentials).
If the entered Username and Password do not match, the program will output “Incorrect Username or
Password”.
Hint: You will scan the rows of the 2D array to search for Username and Password matches.
Error check: The login should only be successful if the Username and Password exist and are in the
same row. The program should not allow a successful login if both the Username and Password
match, but are present in separate rows.
Here is a visualization to help you (These are the first 6 rows of the 2D array, after at least 6 students
have signed up and their usernames and passwords have been saved.)
(The first row with “Usernames” and “Passwords” written on it is just to help you, it does not need to
be in the program)
Usernames Passwords
Ali Abcde
Ahmad3 99912
Omer_34 uaashafdw
ShAHreZ_ 0oiyth
_huzaIFA_ islamabad
hi Lahr21
hello 1212
NOTE: The program should ONLY end if you successfully login. If the login fails, or if you do a successful or
unsuccessful sign up, the program should again show the “Login or Sign up?” menu, and ask for your
username or password.
Sample output:
Write a program that takes in numbers as input from the user and stores them into an integer 1D
array. Now create a function max_min that finds and prints the maximum and minimum integers from
the array.
Part B: [5 marks]
Now create a function sorter which will sort the array in ascending or descending order depending
on the choice of the user.
Note: