(C++) Write a program that ran

(C++) Write a program that randomly fills in 0s and 1s into a5-by-5 matrix,prints the matrix,and finds which row and column withmore 1s and display that row and columnnumber.            

Answer:

#include <iostream>#include <cstdlib>#include <ctime>using namespace std;int main() {    srand(time(NULL));    int arr[5][5];    // randomly fills in 0s and 1s into a 5-by-5 matrix    for (int i = 0; i < 5; ++i) {        for (int j = 0; j < 5; ++j) {            arr[i][j] = rand() % 2;        }    }    // prints the matrix    for (int i = 0; i < 5; ++i) {        for (int j = 0; j < 5; ++j) {            cout << arr[i][j] << " ";        }        cout << endl;    }    cout << endl;    // find row with more 1's    int maxRowIndex = 0, maxOnes = 0;    for (int i = 0; i < 5; ++i) {        int count = 0;        for (int j = 0; j < 5; ++j) {            if (arr[i][j] == 1)                ++count;        }        if (count > maxOnes) {            maxOnes = count;            maxRowIndex = i;        }    }    cout << "row " << maxRowIndex+1 << " is maximum which contains " << maxOnes << " ones" << endl;    // find column with more 1's    int maxColumnIndex = 0;    maxOnes = 0;    for (int i = 0; i < 5; ++i) {        int count = 0;        for (int j = 0; j < 5; ++j) {            if (arr[j][i] == 1)                ++count;        }        if (count > maxOnes) {            maxOnes = count;            maxColumnIndex = i;        }    }    cout << "column " << maxColumnIndex+1 << " is maximum which contains " << maxOnes << " ones" << endl;    return 0;}


 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.