Professional Documents
Culture Documents
Fall 2019 - CS201 - 2
Fall 2019 - CS201 - 2
Fall 2019 - CS201 - 2
2 Total Marks: 20
Semester: Fall 2019 Due Date:
CS201 – Introduction to Programming 02-12-2019
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
- Dev C++
Objectives:
In this assignment, the students will learn:
How to fill / populate a two-dimensional array using random numbers.
How to write user defined functions and pass an array to them as parameter.
How to implement switch statement to process specific options.
How to compare elements of array.
How to find transpose of an array.
You are required to submit only .cpp file on the assignments interface of CS201 at VU-LMS.
Use random number function to populate the array i.e. rand( ). Range should be 1 to 100.
Hint: use srand( ) function before rand( ) to seed the random number. In loop, rand( ) may generate same numbers
so you should use srand(time(0)) before rand( ) to generate different random numbers. To use time(0) you may need
to include time.h header file.
Switch statement will be implemented to perform multiple conditions and to perform different actions based on the
conditions. i.e. Option 1, 2, 3 and 4.
Write user defined functions to perform tasks given in options. Following function names should be used for
consistency.
To populate the array poulateArray( );
To display all elements of Array showElements( );
To show largest element in the array showLargestElement( );
1 If the user choses any option other than “1” at the start when the array is empty, the user should get a
message like “Sorry the array is empty, first populate it by pressing 1 to perform this task ". See the
following sample output:
2 Upon pressing 1, a message like “Array has been populated successfully!" should be displayed. See the
following sample output:
4 Largest number along with its row and column number can be found by pressing 3. Similarly, if the user
presses 4 transpose of the array should be displayed. See the sample outputs for both options:
Good Luck!