1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KIM [24]
3 years ago
6

c Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Each one the arrays cor

responds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. flowchart
Computers and Technology
1 answer:
Komok [63]3 years ago
7 0

Answer:

hope this helps and do consider giving a brainliest to the ans if it helped.

Explanation:

//program to check if the entered grid is magic square or not

/**c++ standard libraries

*/

#include<bits/stdc++.h>

using namespace std;

/**function to check whether the entered grid is magic square or not

*/

int isMagicSquare(int arr[3][3]){

  int i,j,sum=0,sum1=0,rsum,csum;

  for(i=0;i<3;i++){

      sum+=arr[i][i];

      sum1+=arr[i][2-i];

  }

  if(sum!=sum1){

      return 0;

  }

 

  for(i=0;i<3;i++){

      rsum=0;

      csum=0;

      for(j=0;j<3;j++){

          rsum+=arr[i][j];

          csum+=arr[j][i];

      }

      if(sum!=rsum){

          return 0;

      }

      if(sum!=csum){

          return 0;

      }

  }

  return 1;

}

/** main function to get user entries and

* call function

* and print output

*/

int main(){

  int i,j,arr[3][3]={0};

  for(i=0;i<3;i++){

      for(j=0;j<3;j++){

          cout<<"Enter the number for row "<<i<<" and column "<<j<<" : ";

          cin>>arr[i][j];

      }

  }

  int ret = isMagicSquare(arr);

  if(ret==1){

      cout<<"This is a Lo Shu magic square"<<endl;

  }

  else{

      cout<<"This is not a Lo Shu magic square"<<endl;

  }

  return 0;

}

You might be interested in
Which computer program can you use to write, edit, print, and perform any modifications to a document?
faltersainse [42]
D. word-processing software
4 0
4 years ago
Read 2 more answers
In the following code fragment, how many times is the count() method called as a function of the variable n? Use big-O notation,
ahrayia [7]

Answer:

The loop counts the count() function length of n-1 times with respect to n.

Explanation:

The first and outer loop counts for two times as the variable declared in the condition counts before the iteration is made. The same goes for the other for statements in the source code.

The n represents the number length of a range of numbers or iterables (like an array).

4 0
3 years ago
4
kupik [55]

Answer:

the answer is D Smart Object

5 0
3 years ago
Read 2 more answers
Write an algorithm for a program which inputs the lengths a, b and c of the three
Dmitriy789 [7]

Hello,

Answer:

<h2>--//Triangles Algorithm</h2>

Declare the variables of the side of each triangle, in this case, a, b, and c, and input them.

If a^2 == b^2 + c^2

           display "This triangle IS right-angled."

Else

          display "This triangle is NOT right-angled

Explanation:

The meaning of the word "algorithm" in this situation would be the coding of the program that you are assigned to create. I'll use Python in this. Display, in this case, will mean "print"

6 0
3 years ago
Read 2 more answers
A financially stable person is able to:
FinnZ [79.3K]
I think D. To save money cuz thats how financially stable people stay financially stable
7 0
3 years ago
Other questions:
  • To include totals and other statistics at the bottom of a datasheet, click the ____ button on the HOME tab to include the Total
    12·1 answer
  • Most modern TCP implementations use pseudo-random number generators (PRNG) to determine starting sequence numbers for TCP sessio
    13·1 answer
  • A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, cell A3 contains 7. You enter in cell A4 the fo
    15·2 answers
  • Differences between Quality of Services and a Service of Quality approach
    9·1 answer
  • Five aplications of ict​
    10·1 answer
  • Convert the following Base 2 (binary) numbers to base 10(decimal):<br> 11101<br> 1010101
    13·1 answer
  • How many keys are utilized in symmetric cryptography?A. OneB. TwoC. ThreeD. Four
    10·1 answer
  • Write a flowchart and program that does the following: Asks the user for the average temperature in each of the last 12 months A
    12·1 answer
  • What is the difference between word processing software and presentation software​
    9·1 answer
  • Write a program in Python to sum to numbers:<br><br> Urgently needed, please.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!