+ 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)M.Tahir thnkx fr idea of solution plz ye bta dyn k hm is mai maximum r minimum value change kr dyn tu ye change ho jya ga kindly bta dyn .
#include <cstdlib>
#include <iostream>
#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: " max endl;
cout "Array element with minimum value: " min endl 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 = 1; i <= 100; i++)
{
cout *ptr "\t";
ptr++;
if(i%10 == 0)
cout endl;
}
cout endl;
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 minimum sum: " MinimumSumOfAll endl endl;
}
int main(int argc, char *argv[])
{int board[10][10] = {0};
fillBoard(board);
displayBoard(board);
displayMaxMinElement(board);
find(board);
system("PAUSE");
return 0;
}
#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 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 minimum sum: " MinimumSumOfAll endl endl;
}
main()
{
int board[10][10] = {0};
fillBoard(board);
displayBoard(board);
displayMaxMinElement(board);
find(board);
system("pause");
}
#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;
}
void displayrow(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;
: "row"\t""Maximum Sum Is = "maxendl"Row n: "row"\t"" Minimum Sum Is = "minendlendl;
}
Aik hi row m max and min ni dhondna
each row agr max hai thn min another hna chaiye..
in continuing of my previous post,
Sir i need help.assignment kon sy leactures main sy hai?
*****
#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"\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");
}
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.
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