MY SOLVE Q3

Consider a 4-by-4 array of characters. Write a C++ program to accomplish each of the following operations:
a. Declare the above array. [2 marks]
b. Read the array. [4 marks]
c. Find and print the number of zeros in both the diagonals of the array. [14 marks]
d. Replace each even number in the array by zero and then print the array as rows and columns. [10 marks]



#include <vcl.h>
#include "MT262io.h"
#include <iostream.h>
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
char mycharArr [4][4]; // a: Definition

for (int row=0;row<4;row++){ // b: Read the array
for (int column=0;column<4;column++){
//First way to read inputs
cout << "Please Type an integer number : ";
cin >> mycharArr[row][column];
//second way to read inputs
//myIntArr[row][column]=ReadIntPr("Please Type an integer number : ");
}
}


cout <<"\n"<<"zeros in main diagonal only : "<<"\n"; //c :print all zeros
cout <<"==============================="<<"\n";
for (int row=0;row<4;row++){
for (int column=0;column<4;column++){
if(row==column){
if( mycharArr[row][column]=='0')
cout << "we found 0 in " <<"("<<row<<","<<column<<")"<<"\n";
}
}
}
cout <<"\n"<<"zeros in second diagonal : "<<"\n";
cout <<"==============================="<<"\n";
for (int row=0;row<4;row++){
for (int column=0;column<4;column++){
if(row+column==3){
if(mycharArr[row][column]=='0')
cout << "we found 0 in " <<"("<<row<<","<<column<<")"<<"\n";
}
}
}
for (int row=0;row<4;row++){ //d : replace even numbers by zeros
for (int column=0;column<4;column(++ {
if(mycharArr[row][column]%2==0){
mycharArr[row][column]='0';}
}
}
cout <<"\n"<<"Array after replacing even by zero : "<<endl;
cout <<"===================================";
for (int row=0;row<4;row++){
cout <<"\n";
for (int column=0;column<4;column++){
cout << mycharArr[row][column]<<" ";
}
}
getchar();

; return 0
}



CAN ANYONE TELL ME WHERE IS MY PROPLEM THANKES
What problem?

It would help to review the code if you used format "source code" option.
No problem, I just want to make sure of the validity of the solution and not reach the required question
Topic archived. No new replies allowed.