0% found this document useful (0 votes)
7 views7 pages

Assignment 4

The document outlines Assignment No 4 for a Programming Fundamentals course, detailing tasks that require writing C++ programs for various scenarios such as customer feedback ratings, image processing, student name collection, library book tracking, and warehouse stock management. Each task includes specific requirements for code organization, functionality, and output. Submission guidelines are also provided, including file naming conventions and deadlines.

Uploaded by

muzamilch406
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)
7 views7 pages

Assignment 4

The document outlines Assignment No 4 for a Programming Fundamentals course, detailing tasks that require writing C++ programs for various scenarios such as customer feedback ratings, image processing, student name collection, library book tracking, and warehouse stock management. Each task includes specific requirements for code organization, functionality, and output. Submission guidelines are also provided, including file naming conventions and deadlines.

Uploaded by

muzamilch406
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/ 7

Assignment No 4: Programming Fundamentals

Instructor: Sheeza Shabbir Class: BSCS2 Date: 28-06-2025

Note:

1. Read the problem statement thoroughly to understand the requirements and constraints.
2. Ensure a clear understanding of what the program is expected to achieve.
3. Organize the code logically with proper indentation, functions and formatting.
4. Display clear and informative output to convey the results of the program.
5. If needed, include comments in the code to explain complex logic or improve code
readability.
6. Before submission, review the code to ensure it meets the requirements and produces the
expected output.
Guidelines for Submission

1. Name the zip file using the format: YourName_RollNumber.zip


2. Submission Deadline is 6-06-2025 before 12:00 Am.
3. A link will be shared for file submission.
4. Submissions received one hour past the deadline will incur a 30% deduction. Submissions
exceeding a one-hour delay will be deemed unacceptable, resulting in a zero score.
5. Any instance of cheating will lead to a zero score, accompanied by additional penalties
imposed during the session.
Task 1:

Scenario:
A company wants to store customer feedback ratings for a product. They do not know in advance
how many ratings they will receive. The ratings are integers between 1 and 5. Each time a customer
gives a rating; it should be added to the array automatically. If the array is full, it should grow to
accommodate more ratings.

Task:
Write a C++ program that:

1. Implements an auto-growing 1D array (like a simple version of vector).


2. Starts with an initial capacity of 5.
3. Doubles its capacity whenever the array is full.
4. Allows the user to enter as many ratings as they want (until they enter -1 to stop).
5. Displays all ratings entered.
6. Calculates and displays the average rating.
Task 2:

Scenario:
You are designing a simple image processor. An image is represented as a 2D array of pixel
brightness values (integers between 0 and 255). The processor should:

1. Take a matrix as input.


2. Increase the brightness of each pixel by a user-defined value.
3. Make sure no pixel value exceeds 255.
4. Calculate and display the total brightness before and after the increase.

Task:
Write a C++ program that:

1. Declares a 2D array with user-defined rows and columns.


2. Initializes the array with user input.
3. Uses a function to increase brightness.
4. Uses row-wise or column-wise traversal to update pixel values.
5. Uses another function to calculate total brightness.
Task 3:

Scenario:
A teacher wants to collect the names of students who are attending an extra class. The number of
students is not known in advance — students keep arriving and writing their names on a list.
Each name should be stored in a vector<string>, which grows automatically as more students are
added.

Task:

 Use a vector<string> to store student names.


 Keep asking for names until the teacher types "END" to stop.
 After collecting all names, display:

 The total number of students.


 The full list of names.
Task 4:

Scenario:

A library wants to keep track of the number of books borrowed by each visitor in a day. They
don’t know in advance how many visitors will come. The librarian enters the number of books
borrowed by each visitor one by one.

When the day ends (-1 as input), the system should:

 Display all borrowing records.


 Calculate and display:

 Total books borrowed.


 Average books per visitor.
 Maximum and minimum books borrowed by a single visitor.
Task 5:

Scenario:
A small warehouse stores boxes in rows and columns (like shelves). Each cell in a 2D array
represents the number of items in that box. The manager wants:

1. To input the current stock for each box.


2. To check the total stock in the entire warehouse.
3. To find the box with the maximum stock.
4. To restock each box by a certain amount and ensure no box exceeds a limit (e.g., max 100
items per box).

Task:
Write a C++ program that:

1. Declares and initializes a 2D array with user-defined rows and columns.


2. Inputs the stock quantity for each box.
3. Uses a function to calculate total stock.
4. Uses a function to find the box with maximum stock (row, column, and value).
5. Uses a function to increase stock in all boxes by a user-specified value (without exceeding
100).
6. Displays the updated warehouse matrix.

You might also like