#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;
}
Comments
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.
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