Answer to Question #335596 in C++ for Bryan joy Barrientos

Question #335596

Using three dimensional array, create a program that will enter table, row, and column together with the total number of Elements then display the Biggest number, Smallest number, and Second to the biggest number.



Sample input and output:



Input:


Enter number of Tables: 2


Enter number of Rows: 2


Enter number of Columns: 2



Enter 8 number of Elements


2


6


34


76


34


98


56


45



The biggest number among them is: 98


The smallest number among them is: 2


The second to the biggest number is: 76

1
Expert's answer
2022-04-29T18:22:56-0400
#include <iostream>
#include <bits/stdc++.h>


using namespace std;


int main()
{
    int table, rows, colums, i, j;
    cout << "Enter number of Table: ";
    cin >> table;
    cout << "Enter number of Rows: ";
    cin >> rows;
    cout << "Enter number of Colums: ";
    cin >> colums;
    int size = table * rows * colums;
    int arr[size];
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << "Enter " << size << " number of Elements " << endl;
    
    for (i = 0; i < size; i++){
        cin >> arr[i];
    }
    for (i = 0; i < n - 1; i++)
        for (j = 0; j < n - i - 1; j++)
            if (arr[j] > arr[j + 1])
                swap(arr[j], arr[j + 1]);
    cout << "The biggest number among them is: " << arr[size-1] << endl;
    cout << "The smallest number among them is: " << arr[0]<< endl;
    cout << "The second to the biggest number is: " << arr[size-2]<< endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS