We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

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.

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 9272

.

+ 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)

Replies to This Discussion

hmien sirf all rows m se maximum an minimum sum wali row find krna hai...

plz detai ain bta dyn


The concept of arrays is related to that of pointers. In fact, arrays work very much like pointers to their first elements, and, actually, an array can always be implicitly converted to the pointer of the proper type. For example, consider these two declarations:

1
2
 myarray [20];  * mypointer;



The following assignment operation would be valid: 

 
mypointer = myarray;



After that, mypointer and myarray would be equivalent and would have very similar properties. The main difference being that mypointer can be assigned a different address, whereas myarray can never be assigned anything, and will always represent the same block of 20 elements of type int. Therefore, the following assignment would not be valid:

 
myarray = mypointer;



Let's see an example that mixes arrays and pointers:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// more pointers #include <iostream>   std;   main () {    numbers[5];    * p;   p = numbers;  *p = 10;   p++;  *p = 20;   p = &numbers[2];  *p = 30;   p = numbers + 3;  *p = 40;   p = numbers;  *(p+4) = 50;    ( n=0; n<5; n++)     cout  numbers[n]  ", ";    0; }
10, 20, 30, 40, 50, 

if anyone wants help i can help him understanding the assignment 

as the main goal is to understand programming instead of copy pasting :)

yes Rafay guide about ths assignment 

explain

Yes Rafay Javed please guide me.

you guys understanding , that how other functions are working ?

and did you read try to make solution?

what and where you guys are facing problem? I'll not give you guys the code as its only 3-4 lines we have to add/edit 

so I'll help you guys to solve problem and let you learn programming along , as its the key course

so share here how much code u understand and what do you think about modifying it :)

<id 61007 translation missing>

ye err ata ha jab ye code dev main run krta ho to.

please tell me how can i fix this?

hi, dear agr aap ko easy hoto main apko code txt main bhjta hun , muje code under stand krna hai , nd is main se samj nai lag rahi k program kesy execute hoga , so kindly agr aap .txt mian is code k sath comments paste kr dain to muje samjne main asani ho jay gi.

anisvirtualuni2014@gmail.com

 

i shall be thankful to u .... 

#include <iostream> 
#include <stdlib.h>
#include <time.h>
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"\n\nArray element with maximum value: "maxendl;
cout"Array element with minimum value: "minendlendl;
}
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: "maxendl;
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);
cout "Thank you and Luv U brother as u tried to help me,,,! Anis Ur Rehman :)";
system("pause");
}

#include <iostream>
#include <stdlib.h>
#include <time.h>
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"\n\nArray element with maximum value: "maxendl;
    cout"Array element with minimum value: "minendlendl;    
}

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: "maxendl;
    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");    
}    

RSS

Latest Activity

Farhan Amin replied to Farhan Amin's discussion your vu email address will deleted
11 minutes ago
Farhan Amin replied to Farhan Amin's discussion your vu email address will deleted
11 minutes ago
+ ! ! ! ! ! AaiMa AnsaRi liked + M.Tariq Malik's discussion CS201 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 14-11-2019
22 minutes ago
+ ! ! ! ! ! AaiMa AnsaRi replied to + M.Tariq Malik's discussion MGT211 GDB Fall 2019 Solution & Discussion in the group MGT211 Introduction To Business
23 minutes ago
+ ! ! ! ! ! AaiMa AnsaRi joined + M.Tariq Malik's group
23 minutes ago
+ ! ! ! ! ! AaiMa AnsaRi liked + M.Tariq Malik's discussion MGT211 GDB Fall 2019 Solution & Discussion
27 minutes ago
+ Abb@s replied to Farhan Amin's discussion your vu email address will deleted
43 minutes ago
+ Danial replied to Farhan Amin's discussion your vu email address will deleted
1 hour ago
Shine--Ex-VUStudent liked + "J ɨ y ą ⋆'s discussion meliiiiiiii dailyyyyyyyyyyyyyyyyy milkkkkkkkkkkkkkkkkk :(
1 hour ago
+ Danial replied to Farhan Amin's discussion your vu email address will deleted
1 hour ago
Shine--Ex-VUStudent liked +"Certified Gangster"++'s discussion New invention of Microsoft
1 hour ago
Moji posted a discussion
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT211 GDB Fall 2019 Solution & Discussion in the group MGT211 Introduction To Business
1 hour ago
Muhammad Usman Shahzad replied to + M.Tariq Malik's discussion CS601 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 14-11-2019 in the group CS601 Data Communication
1 hour ago
Muhammad Usman Shahzad joined + M.Tariq Malik's group
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to sayyad saqib hussain shah's discussion HRM 626 HANDOUTS REQUIRED PLS
2 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to Farhan Amin's discussion your vu email address will deleted
2 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MTH302 Business Mathematics & Statistics Assignment No 01 Fall 2019 Solution & Discussion in the group MTH302 Business Mathematics & Statistics
2 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MTH302 Business Mathematics & Statistics Assignment No 01 Fall 2019 Solution & Discussion in the group MTH302 Business Mathematics & Statistics
2 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MTH302 Business Mathematics & Statistics Assignment No 01 Fall 2019 Solution & Discussion in the group MTH302 Business Mathematics & Statistics
2 hours ago

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

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