Answer to Question #100868 in C++ for w

Question #100868
/Write a program that asks the user to enter integer numbers and store the numbers in a two
dimensionalarray,thenreplaceany9digitby0digit.Afterthatreplacethenumberswiththeodd
summations indices by the even summation indices.

(you should submit two solutions, one with the usage of Array and the
other without.)
1
Expert's answer
2020-01-03T03:11:00-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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS