+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
Assignment No. 02 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:
Objective
The objective of this assignment is to provide an on hand experience of:
Guidelines
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.
Submission You are required to submit your code through LMS in .cpp file format. |
Tags:
+ 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)hmien sirf all rows m se maximum an minimum sum wali row find krna hai...
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:
|
|
The following assignment operation would be valid:
|
|
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:
|
|
Let's see an example that mixes arrays and pointers:
|
|
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 :)
explain
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");
}
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post