I WROTE THE CODE :
#include<conio.h>
#include <iostream>
using namespace std;
int main()
{
const int ROWSIZE=4,COLSIZE=4;
int tricky=0,i,j;
int sum;
int play1[ROWSIZE][COLSIZE]={{1,5,3,7},
{6,8,5,8},
{3,3,3,5},
{7,8,1,5}
};
int play2[ROWSIZE][COLSIZE]={{4,6,3,7},
{5,0,7,8},
{8,7,6,5},
{7,3,4,5}};
for(i=0;i<ROWSIZE;i++)
{
for(j=0;j<COLSIZE;j++)
{
if(play1[i][j]==play2[i][j])
{
tricky=tricky+play1[i][j];
}
else
{
sum=play1[i][j]+play2[i][j];
tricky=tricky+sum;
}
}
}
cout<<"The value of the tricky:"<<tricky;
return 0;
}
OUTPUT:
QUESTION 4 16 marks 4.1 4.2 Declare two integer constants ROWSIZE equal to 4 and COLSIZEequal...
4.1 4.2 (4) (4) Declare two integer constants ROWSIZE equal to 4 and COLSIZEequal to 4. Declare two inttwo-dimensional arrays, namely playlwith ROWSIZEnumber of rows and COLSIZEnumber of columns, and play2with ROWSIZEnumber of rows and COLSIZEnumber of columns, 4.3 Assume that values have been assigned to all the elements of playland play2. Also assume that an int variable trickyhas been declared and intialised to 0. Use nested forloops and write down the necessary C++ statements to do the following: Each...
QUESTION 4 16 marks 4.1 4.2 (4) (4) Declare two integer constants RONGI ZE equal to 4 and Ca.SI ZEequal to 4. Declare two i nt two-dimensional arrays, namely playlwith ROWI ZEnumber of rows and COLSI ZEnumber of columns, and play2with RONGI ZEnumber of rows and COLSI ZEnumber of columns, 4.3 Assume that values have been assigned to all the elements of pl ayland play 2. Also assume that ani nt variable trickyhas been declared and intialised to 0. Use...
QUESTION 4 16 marks 4.1 4.2 (4) (4) Declare two integer constants RONGI ZE equal to 4 and Ca.SI ZEequal to 4. Declare two i nt two-dimensional arrays, namely playlwith ROWI ZEnumber of rows and COLSI ZEnumber of columns, and play2with RONGI ZEnumber of rows and COLSI ZEnumber of columns, 4.3 Assume that values have been assigned to all the elements of pl ayland play 2. Also assume that ani nt variable trickyhas been declared and intialised to 0. Use...
QUESTION 4 16 marks 4.1 4.2 Declare two integer constants ROWI ZE equal to 4 and CO.SI ZEequal to 4. (4) Declare two i nt two-dimensional arrays, namely (4) playlwith ROMSI ZEnumber of rows and COL SI ZE number of columns, and pl ay2 with ROMI ZEnumber of rows and COL SI ZEnumber of columns, 4.3 Assume that values have been assigned to all the elements of pl ayland play. Also assume that ani nt variable tricky has been declared...
4.3 Assume that values have been assigned to all the elements of playland play2. Also assume that an int variable trickyhas been declared and intialised to 0. Use nested forloops and write down the necessary C++ statements to do the following: Each row of playlis compared element by element to the corresponding row of play2. If the elements are equal, add the value of one element to tricky. If the elements are not equal, add the sum of the two...
QUESTION 4 16 marks 4.1 Declare two integer constants ROWSIZE equal to 4 and COLSIZEequal to 4. (4) 4.2 Declare two inttwo‐dimensional arrays, namely play1with ROWSIZEnumber of rows and COLSIZEnumber of columns, and play2with ROWSIZEnumber of rows and COLSIZEnumber of columns 4.3 Assume that values have been assigned to all the elements of play1and play2. Also assume that an int variable trickyhas been declared and intialised to 0. Use nested forloops and write down the necessary C++ statements to do the following:...
4.1 Declare two integer constants ROWSIZE equal to 4 and COLSIZEequal to 4.
Write a program that reads a matrix from the keyboard and displays the summations of all its rows on the screen. The size of matrix (i.e. the number of rows and columns) as well as its elements are read from the keyboard. A sample execution of this program is illustrated below: Enter the number of rows of the matrix: 3 Enter the number of columns of the matrix: 4 Enter the element at row 1 and chd umn 1: 1...
Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8 9 10 11; 23 9 16 15 ;11 12 3 6; 1 2 8 9 ) ? = ( 2 21 7 15; 12 4 8 22; 23 9 5 13; 23 4 21 22) ℎ = (4 9 12 15) b. Add suitable lines of codes to the M-file to do the following. Each of the following points should be coded in only...
S.A vector IS givell by [5, 17,-3, 8, 0,-7, 12, 15, 20,-6, 6, 4,-7, 16]. Write a program as a 3 or 5, and, raises to the power of 3 the elements that are script tile that doubles the elements that are positive and are divisible by negative but greater than -5. following values. The value of each element in the first row is the number of the 6. Write a program in a script file that creates an matrix...