www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Assignment No. 02
Semester: Spring 2015

CS201: Introduction to Programming

Total Marks: 20

Due Date: 12/06/2015

Lectures Covered: 7 to 16

 

Please read the following instructions carefully before submitting assignment.

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.

 


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 9382

Replies to This Discussion

#include
#include
#include
using namespace std;
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 "Array element with maximum value:" max endl;
cout "Array element with minimum value: " min endl endl;
}
void displayMaxMinRow(int array[10][10])
{
int sum = 0, max = 0, min = 1000, row;
for(int i=0;i<10;i++)
{
for(int j=0; j<10; j++)
{
sum = sum + array[i][j];
}
if(sum <= min)
{
min = sum;
row = i+1;
}
if(sum >= max)
{
max = sum;
row = i+1;
}
sum = 0;
}
cout "\n\nRow no. " row " has maximum sum: " max endl;
cout "Row no. "row" has minimum sum: " minendlendl;
}
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 = 1; 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);
displayMaxMinRow(board);
system("pause");
}
#include
#include
#include
using namespace std;

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"\nArray element with maximum value: "maxendlendl;
cout"Array element with minimum value: "minendlendl;
}

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 = 1; i <= 100; i++) {
cout*ptr"\t";
ptr++;

if(i%10 == 0)
coutendl;
}
coutendl;
ptr = NULL;
}

void find(int array[10][10])
{
int SumOfEachRow = 0;
int MaximumSumOfAll = 0;
int MaximumRow = 0;
int MinimumRow = 0;
int MinimumSumOfAll = 10000;
for(int i = 0; i < 10; ++i) {
SumOfEachRow = 0;
for(int j = 0; j < 10; ++j) {
SumOfEachRow += array[i][j];
}
if (SumOfEachRow >= MaximumSumOfAll) {
MaximumSumOfAll = SumOfEachRow;
MaximumRow = i + 1;
}
if (SumOfEachRow <= MinimumSumOfAll) {
MinimumSumOfAll = SumOfEachRow;
MinimumRow = i + 1;
}
}
cout "Row No. " MaximumRow " has maximum sum: " MaximumSumOfAll endl;
cout "Row No. " MinimumRow " has maximum sum: " MinimumSumOfAll endl endl;
}

main() {

int board[10][10] = {0};
fillBoard(board);

displayBoard(board);
displayMaxMinElement(board);

find(board);

system("pause");
}

Guys you must follow lectures and do practices if you dont follow lectures you will not able to submit a single upcoming assignment with proper solution
since you just cannot copy paste code neither explain it in your audio narration unless you understand the codes.

VU management should give us recording in which they elaborate coding .. or they can just record online sessions.

Unfortunately i'll not submit this assignment since I have no Idea what is going on..

koe correct solutin bta dy

RSS

Looking For Something? Search Below

Latest Activity

+ M.Tariq Malik replied to + M.Tariq Malik's discussion ENG101 English Comprehension Assignment 01 Fall 2020 Solution / Discussion in the group ENG101 English Comprehension
43 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion ENG101 English Comprehension Assignment 01 Fall 2020 Solution / Discussion in the group ENG101 English Comprehension
43 minutes ago
Profile Iconasad mehmood, Muniba shahid and H@di_a joined + M.Tariq Malik's group
44 minutes ago
+!!★彡 "Mannat"彡★✓ commented on Zoha n's blog post Your Goal..
53 minutes ago
+!!★彡 "Mannat"彡★✓ commented on Heart attacker'++!!'s blog post "Itx about"
57 minutes ago
+!!★彡 "Mannat"彡★✓ liked Heart attacker'++!!'s blog post "Itx about"
58 minutes ago
+!!★彡 "Mannat"彡★✓ liked +!!★彡 "Mannat"彡★✓'s discussion Plz briefly explain these questionsssssss..........
1 hour ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion MGT101 Financial Accounting Assignment 01 Fall 2020 Solution / Discussion in the group MGT101 Financial Accounting
1 hour ago
+!!★彡 "Mannat"彡★✓ posted a discussion
1 hour ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion ZOO505 Cell and Molecular Biology Assignment No 03 Fall 2020 Solution & Discussion in the group ZOO505 Cell and Molecular Biology
1 hour ago
+ M.Tariq Malik liked + M.Tariq Malik's discussion ZOO505 Cell and Molecular Biology Assignment No 03 Fall 2020 Solution & Discussion
1 hour ago
+ M.Tariq Malik added a discussion to the group ZOO505 Cell and Molecular Biology
1 hour ago

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.