Question

In: Computer Science

C programming. Write a program that prompts the user to enter a 6x6 array with 0...

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.

Solutions

Expert Solution

#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


Related Solutions

IN C++ Write a program that prompts the user to enter the number of students and...
IN C++ Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score (display the student’s name and score). Also calculate the average score and indicate by how much the highest score differs from the average. Use a while loop. Sample Output Please enter the number of students: 4 Enter the student name: Ben Simmons Enter the score: 70 Enter the student name:...
JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a...
JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and displays the number in a fraction. Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template at https://liveexample.pearsoncmg.com/test/Exercise13_19.txt for your code. Sample Run 1 Enter a decimal number: 3.25 The fraction number is...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Write a program in c++ using only if statements that prompts the user to enter an...
Write a program in c++ using only if statements that prompts the user to enter an integer for today’s day of the week (Sunday is 0, Monday is 1 …., and Saturday is 6) then displays today. Also, prompt the user to enter the number of days after today for a future day and display the future day of the week. The future day can be computed as follows: (today + number of days after today) % 7 Sample run...
Include<stdio.h> In C program Write a program that prompts the user to enter an integer value....
Include<stdio.h> In C program Write a program that prompts the user to enter an integer value. The program should then output a message saying whether the number is positive, negative, or zero.
write a c++ program that prompts a user to enter 10 numbers. this program should read...
write a c++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the two numbers and the average of the 10 numbers PS use file I/o and input error checking methods
( USE C++ ) The program prompts the user to enter a word. The program then...
( USE C++ ) The program prompts the user to enter a word. The program then prints out the word with letters in backward order. For example, if the user enter "hello" then the program would print "olleh" show that it works .
Write a C++ program which prompts the user to enter an integer value, stores it into...
Write a C++ program which prompts the user to enter an integer value, stores it into a variable called ‘num’, evaluates the following expressions and displays results on screen. num+5, num-3, (num+3) – 2, ((num+5)*2 / (num+3)) For performing addition and subtraction, you are allowed to use ONLY the increment and decrement operators (both prefixing and postfixing are allowed). You must remember that using increment/decrement operators changes the original value of a number. Indent your code and include comments for...
Write a C++ console program that prompts a user to enter information for the college courses...
Write a C++ console program that prompts a user to enter information for the college courses you have completed, planned, or are in progress, and outputs it to a nicely-formatted table. Name the CPP as you wish (only use characters, underscores and number in your file name. DO NOT use blank). Its output should look something like this: Course Year Units Grade ---------- ---- ----- ----- comsc-110 2015 4 A comsc-165 2016 4 ? comsc-200 2016 4 ? comsc-155h 2014...
C++ Write a program that prompts the user to enter 50 integers and stores them in...
C++ Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs separated by a ';'. An example of the program is shown below: list[0] = 15 is the sum of: ----------------------...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT