Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; int main() { int Matrix [4][4], r=4, c=4, i, j,k,sumc=0, sumr=0,sumd1=0,sumd2=0,sumd; for(i=0 ; i for (j=0 ; j if (k%2!=0)

image text in transcribed

#include #include using namespace std; int main() { int Matrix [4][4], r=4, c=4, i, j,k,sumc=0, sumr=0,sumd1=0,sumd2=0,sumd;

for(i=0 ; i

for (j=0 ; j

if (k%2!=0) { Matrix[i][j]=k; cout

for(i=0 ; i

cout

for(i=0 ; i

cout

for(i=0 ; i

for(i=0 ; i

sumd=sumd1+sumd2;

cout

cout

for(i=0 ; i

for(i=0 ; i

for(i=0 ; i

cout

for(i=0 ; i

cout

for(i=0 ; i

for(i=0 ; i

sumd=sumd1+sumd2;

cout

return 0; }

Problem 3 Declare a two dimensional array of the type int named Matrix of the size 4 x 4, i.e. 4 rows and 4 columns. Initialize the array such that the first two columns are initialized to the first 8 even numbers, and the last two columns are initialized to first 8 odd numbers, display the array Matrix as shown in the sample input/output. Calculate and display the sum of the elements of the first column, fourth row, and diagonals. Now multiply the first and the fourth columns of the Matrix by 2, display the array and the sum of the elements of the first column, fourth row and diagonals. Sample input / output: 8 1 9 2 10 3 11 4 12 5 13 6 14 15 um of the first column is: 12 Sum of the fourth row is: 42 Sum of the diagonals is: 60 After the multiplication 0 8 1 18 4 10 3 22 8 12 5 26 12 14 30 Sum of the first column is 24 Sum of the fourth row is: 63 Sum of the diagonals is:90

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions