www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Assignment No. 02
Semester: Spring 2015

CS201: Introduction to Programming

Total Marks: 20

Due Date: 12/06/2015

Lectures Covered: 7 to 16

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

• The assignment is submitted after due date.
• The submitted assignment does not open or file is corrupt.
• Assignment is copied(partial or full) from any source (websites, forums, students, etc)
• Assignment solution is not in .cpp file format.

Objective

The objective of this assignment is to provide an on hand experience of:

• Learn to code, edit, compile and execute C++ program.
• Learn to use two dimensional array declaration and manipulation.
• Learn to manipulate array with the help of pointer
• Learn to create user defined functions

Guidelines

• Code should properly be indented and well commented.
• Follow C/C++ naming conventions while using variables, functions etc.
• Use only Dev-C++ for this assignment. If you are using any other tool then mention the name of tool and version on top of your code file as comments.

Assignment Description

This assignment is divided into two parts. In first part, you will be provided with sample startup code (attached with this assignment in folder Startup Code) that will populate 2D array with random numbers from 1 to 100 and display on console. Given code also finds the element with maximum and minimum values in array. Output of sample code is given below as Figure 1. We will help you to understand and practice the given code through Adobe Connect lab sessions. For details of lab sessions see announcement of Adobe Connect Lab Sessions.

The displayMaxMinElement( ) function in startup code that is finding maximum and minimum element will help you get the desire output. To get the desired output, you should find the sum of each row and compare with sum of other rows to find which row’s sum is maximum. The same procedure can be used to find row which have minimum sum as compare with other rows in 2D array.

 Figure 1: Sample output of the Startup code Your Task In this part of assignment, you have to modify given startup code and find the row from 2D array whose sum is maximum as compared with sum of other rows. You also have to find the row whose sum is minimum as compared with other rows. Screen shot of the desire output is given in Figure 2. Figure 2: Sample Desired output

Submission

You are required to submit your code through LMS in .cpp file format.

Views: 9461

### Replies to This Discussion

ye run hua kia?

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

Dear Students Don’t wait for solution post your problems here and discuss ... after discussion a perfect solution will come in a result. So, Start it now, replies here give your comments according to your knowledge and understandings....

kya hum usi prg m add kr sakty hn?

yes us program main he add kerin gay

Assignment File

Attachments:

How to modify the code kindly anyone can help me ?

what function is needed to modify code ?

did u read the function names?

the function with the name display , we have to edit that one

how to find max and min row?

any one help me in this assint

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

void displayMaxMinElement(int array[10][10]){

int max=0,min=100;

for(int i=0;i<10;i++) {

for(int j=0;j<10;j++) {

if(array[i][j]  <= min)

min=array[i][j];

if(array[i][j] >= max)

max=array[i][j];

}

}

cout"\n\n Array Element with maximum value:"maxendl;

cout"Array Element with Minimum valaue: " minendlendl;

cout"Row No.8 has maximum sum:"array[6][0]+array[6][1]+array[6][2]+array[6][3]+array[6][4]+array[6][5]+array[6][6]+array[6][7]+array[6][8]+array[6][9]endl;

cout"Row No.7 has minumum sum:"array[7][0]+array[7][1]+array[7][2]+array[7][3]+array[7][4]+array[7][5]+array[7][6]+array[7][7]+array[6][8]+array[6][9]endl;

}

void fillBoard(int array[10][10]) {

srand(time(0));

for(int i=0;i<10;i++)

{

for(int j=0;j<10;j++)

{

array[i][j]=rand()%100+1;

}

}

}

void displayBoard(int array[10][10])

{

int *ptr = *array;

for(int i=0;i<=100;i++)

{

cout*ptr"\t";

ptr++;

if(i%10==0)

coutendl;

}

coutendl;

ptr=NULL;

}

main()

{

int board[10][10] = {0};

fillBoard(board);

displayBoard(board);

displayMaxMinElement(board);

system("pause");

return 0;

}

1

2

3

4

## Latest Activity

Karina Lopez left a comment for Umm-e-Aimen
49 minutes ago
Karina Lopez left a comment for Huma noor
49 minutes ago
Karina Lopez left a comment for Sparking TwinKle
50 minutes ago
Karina Lopez left a comment for Ruqia
50 minutes ago
Karina Lopez left a comment for Suha Khan
50 minutes ago
Karina Lopez left a comment for Batool
53 minutes ago
Karina Lopez left a comment for Student
54 minutes ago
Karina Lopez left a comment for Muhammaad Arif
54 minutes ago