In: Computer Science
C programming. Write a program that prompts the user to enter a 6x6 array with 0 and 1, displays the matrix, and checks if every row and every column have the even number of 1’s.
#include <iostream>
using namespace std;
int main()
{
int arr[6][6];
printf("Enter 0's and 1's into 6 * 6 Array: ");
for(int i=0;i<6;i++){
for(int j=0;j<6;j++){
scanf("%d",&arr[i][j]);
}
}
int count1=0,count2=0,flag=1;
for(int i=0;i<6;i++){
count1=0,count2=0;
for(int j=0;j<6;j++){
if(arr[j][i]==1)
count1++;
if(arr[i][j]==1)
count2++;
printf("%d",arr[i][j]);
}
printf("\n");
if(count1%2!=0 || count2 % 2!=0){
flag=0;
break;
}
}
if(flag)
printf("The matrix rows and cols has even number of
1's");
else
printf("The matrix rows and cols does not haave even
number of 1's");
return 0;
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me