CS201 Assignment No 02 Spring 2017 Solution and Discussion | Virtual Study Solutions

Adsetra Ads

 

CS201 Assignment No 02 Spring 2017 

Dear students, Here You can read and Download complete assignment and its Solution of CS201 - Introduction to Programming Assignment No 2 Spring 2017. Deadline for this assignment is May 22, 2017. You are required to submit your assignment in .cpp format. Assignment submitted in any other format will be graded with ZERO marks. Previously we shared CS201 Assignment No 1 Solution Spring 2017.
CS201 Assignment No 02 Spring 2017 Solution and Discussion
CS201 Assignment No 02 Spring 2017 Solution and Discussion

Recommended : CS201 Solved Questions and Solved MCQs 2017

Your assignment must be submitted before or on due date. We'll not accept any assignment after the due date through email.

Please Note:

In case of any confusion regarding assignment statement or understanding the related concepts, we strongly recommend you to join the Virtual Visiting Hours and Programming Lab sessions scheduled in the coming week.

Recommended : CS201 Solved Short Notes 2017

CS201 Assignment No 02

You will need to use a two-dimensional array with five rows and five columns for this assignment.

Task 1:

First of all, you will need to populate this 5x5 array with random numbers from 1 to 100. For this purpose create a function named populateArray() which will load the two-dimensional array with random numbers from 1 to 100.

Task 2:

Create a function named displayArray() which will display the contents of this multi-dimensional array on the console as shown in the sample output.

Task 3:

The final task is to find the maximum and minimum number in this array and display it on the console. For this purpose create a function findMaxMinNumber().

Sample output:


CS201 Assignment No 02 Sample output
CS201 Assignment No 02 Sample output
Recommended : DevC++ Installation and Usage Complete Guidelines

CS201 Assignment No 02 Solution

Solution idea:

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
void populateArray(int array[5][5])
{
int ab[5][5];
srand(time(NULL));
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
{
int random = rand() % 100 + 1;
array[i][j] = random;
}
}
}
void displayArray(int array[5][5])
{
cout << "\nDispalying Arrays Data......\n";
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
{
cout << array[i][j] << "\t"; 
}
cout << endl;
}
}
void FindMaxMinNumber(int array[5][5])
{
int min = array[0][0];
int max = min;
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
{
if(array[i][j] < min)
{
min = array[i][j];
}
if(array[i][j] > max)
{
max = array[i][j];
}
}
}
cout << "\nMaximum Value In Array : " << max;
cout << "\nMinimum Value In Array : " << min;
}
int main()
{
int array[5][5];
populateArray(array);
displayArray(array);
FindMaxMinNumber(array);
}

Download CS201 Assignment No 02 Soluton

You can download the assignment solution file in .cpp format from the link below:


If you liked this Solution Please Like us on Facebook and Subscribe us below. Thank You

Post a Comment

 

Top