Answer to Question #100724 in C++ for A

Question #100724
Write a program that asks the user to enter integer numbers and store the numbers in a two-dimensional array,thenreplaceany9digitby0digit.Afterthatreplacethenumberswiththeodd
summations indices by the even summation indices.
1
Expert's answer
2019-12-24T04:43:19-0500

#include <iostream>

#define num 4

using namespace std;


int main()

{

cout << "Enter integers (16):" << endl;

int arr[num][num];

int i;

for (i = 0; i < 4; i++)

{

int j = 0;

for (j = 0; j < 4; j++)

{

cin >> arr[i][j];

}

}

cout << "\nYour array:" << endl;

for (i = 0; i < 4; i++)

{

int j = 0;

for (j = 0; j < 4; j++)

{

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

}

cout << endl;

}

cout << "\nYour new array (changed 9 to 0):" << endl;

for (i = 0; i < 4; i++)

{

int j = 0;

for (j = 0; j < 4; j++)

{

if (arr[i][j] == 9) arr[i][j] = 0;

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

}

cout << endl;

}

cout << "\nYour final array (changed 9 to 0, then all numbers with the odd summations indices replaced by arr[1][1]):" << endl;

for (i = 0; i < 4; i++)

{

int j = 0;

for (j = 0; j < 4; j++)

{

if ((i+j)%2 == 1) arr[i][j] = arr[0][0];

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

}

cout << endl;

}

system("pause");

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

Assignment Expert
25.12.19, 10:53

Dear Zahra, Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you.

Zahra
25.12.19, 09:46

Write a program that will find the inverse of any two dimensional array without the usage of the built-in function by do while loop if possible ,for loop if possible,while loop if possible thanks a lot for help

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS