CS201P Assignment 2 Solution 2021

CS201P Assignment 2 Solution

Assignment No. 2
Semester: Fall 2021

CS201P Assignment 2 Solution 2021

Total Marks: 20

Due Date:31st December, 2021




Please read the following instructions carefully before submitting assignment:

It should be clear that your assignment will not get any credit if:


  1. Assignment is submitted after due date.
  2. Submitted assignment does not open or file is corrupt.
  3. Assignment is copied (From internet/students).


Software allowed to develop Assignment

–          Dev C++


In this assignment, the students will learn:

To fill a two-dimensional array using given data.

How to write user defined functions and pass an array to them as parameter.

How to use if statement and for loop.

Display array elements.

 Assignment Submission Instructions

You are required to submit only.cppfile on the assignments interface of CS201P at VU-LMS. Assignment submitted in any other format will not be accepted and will be graded zero marks. So, check your solution file format before submission.

For any query related to assignment, please contact cs201p@vu.edu.pk

Labs: 4 to 6



CS201P Assignment 2 Solution :


Problem Statement

Units of electricity consumption are given in the form of matrix in source data. You are required to write user defined functions and create a repeating menu in C++ keeping in mind the following requirements:

    1. Student’s VU ID should be displayed on the top of menu.
    2. Press 1 to display the bill of slab 1 and slab 2.

(Hint: In slab 1, unit range is 0 to 100, each unit costs Rs.10, and the data of slab 1 is in the first row of the matrix. While in slab 2, unit range is 101-200, each unit costs Rs.15, and the data of slab 2 is in the second row of the matrix)

    1. Press 2 to display the bill of slab 3.

(Hint: In slab 3, unit range is 201 to 300, each unit costs Rs.20, and the data of slab 3 is in the third row of the matrix.)

    1. Press any other key to exit.

Source data:

(Use two-dimensional array to store the following matrix)

Instructions to write C++ program:


  • Use the given source data. If you do not use it, your marks will be deducted.
  • Write functions to calculate and display cost for slab 1, slab 2, slab 3 from the given source matrix. Following function names should be used for consistency.


To calculate and display cost for slab 1 costSlab1();
To calculate and display cost for slab 2 costSlab2();
To calculate and display cost for slab 3 costSlab3();

Wish you Good Luck!

Lectures Covered:  This assignment covers Labs#4-6.

Deadline: The deadline to submit your assignment solution is31st December, 2021. Your assignment must be submitted within the due date through VU-LMS. No assignment will be accepted through email after the due date.

CS201P Assignment 2 Solution :