Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2-Atsignmentos.pt-Adobe Acrobst iester U. Fil: Ei Vi Windom Helo Home Tools CS52

ID: 3876174 • Letter: 2

Question

2-Atsignmentos.pt-Adobe Acrobst iester U. Fil: Ei Vi Windom Helo Home Tools CS52-Assignment sign In Problem 1 Matrix 6 points Export PU Create a 5x5 matrix of int values as shown below. Write a program that finds the minimum., maximun. average value of all values in the malrix. Creale a function for each value that is computed (max min. avg). Print out the results (limit the average to two decimal points!) Adobe Export PDF Select POF Fie S52-Asignme.ar X Malrix:[ 7, 2, 10, 3,6, 1, 12, 2, 0, 201, t3,14,19, 5, 4]. I 6, 0, 17, 18, 81, 1, 13, 10, 9, 111; Microecht wend (".da) Ccoament Langusg Enqlsh (us change Example: Min: 0, Max: 20, Avq: 9.04 Covert Problem 2 Dynamically Allocated Arrays 9 points Create PDF Write a progTa that dynamically allocates an aray based on a size deteied by the user. You must declare the array as a pointer to get full credit! The program then uses a pointer to initialize each element in the array with a value that is also entered by a user. Finally, sort the aray and print it to the console Comment Combine Files Example Example 2 Knter a size 3 Item 1: 15 Item 2: Item 3: 7 Sorted: 3, 7, 15 organize pages Hill& Sign Send tar Signature Item 1 3 Item 2: 8 Item 1: 2 ILem 5: 9 Sorted 2, 3, 5, 8, 9 -. Send & Track Stare and share files in Dotument Cluud Lesm More OAsk me aniything e

Explanation / Answer

1.

#include <iostream>

#include<iomanip>

using namespace std;

int main() {

int N=5;

int matrix[5][5];

int min=100000;

int max=-100000;

int sum=0;

for(int i=0;i<N;i++){ //taking input in the matrix

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

cout<<"Enter value in the matrix: ";

cin>>matrix[i][j];

}

}

//calculating min,max and avg

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

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

if(min>matrix[i][j]){

min = matrix[i][j];

}

if(max<matrix[i][j]){

max = matrix[i][j];

}

sum = sum+matrix[i][j];

}

}

float avg = sum/25;

cout<<"Max: "<<max<<" Min: "<<min<<" Avg: ";

std::cout << std::fixed << std::setprecision(2) << avg;

}

2.

#include <iostream>

using namespace std;

int main() {

int *arr;

int size;

cout<<"Enter a size: ";

cin>>size;

arr = new int[size];//dynamically initializing array;

for(int i=0;i<size;i++){ //taking input

cout<<"Item "<<i<<": ";

cin>>arr[i];

}

//sorting

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

for(int j=i+1;j<size;j++){

if(arr[i]>arr[j]){

int temp = arr[i];

arr[i] = arr[j];

arr[j] = temp;

}

}

}

cout<<"Sorted: ";

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

cout<<arr[i]<<" ";

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote