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]
2 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]2 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
Julie: 3: 36, 6:72, 9:108....tell me the next 3 ratios * math*
svlad2 [7]

Answer:

12:144, 15:180,

Explanation:

8 0
3 years ago
Solve for x<br><br>4d+3/8=-2​
Alexxx [7]

Answer:

-19/32

Explanation:

(If I assume d to be x)

4x+3/8=-2

or,4x=-2-3/8=-19/8

or,x=(-19/8)*(1/4)=-19/32

5 0
3 years ago
Which one of the following media is unguided media ?​
krok68 [10]

Explanation:

1. radio transmission.

2. microwave transmission

3. infrared transmission.

4 0
2 years ago
Write the C++ statement to declare and initialize a 5-element, one-dimensional integer array named grades. Use the following gra
wolverine [178]

Answer:

int grades[5] = { 100, 90, 80, 78, 98 };

for(int i=0;i<5; i++)

{

  cout << grades[i];

}

4 0
3 years ago
Which image file format is the most widely used?
Ostrovityanka [42]

Answer: jpeg because its a lot of people use it for quaity

7 0
2 years ago
Other questions:
  • The sequence of folders to a file or folder is known as its _______.
    6·1 answer
  • Mrs. Golden wanted to collect baseline data on how often Lauren speaks to her neighbors during silent reading. He divided the 15
    9·1 answer
  • Display flight number, origin, destination, fl_orig_time as --"Departure Time", fl_dest_time as "Arrival Time". Format times in
    8·1 answer
  • Describe shortly about the following Linux directories and theirpurpose,1. lib2. etc3. Boot4. Root5. home
    6·1 answer
  • What type of font color should Kim select if she chooses a dark-colored design theme for her presentation?
    11·2 answers
  • Test Average and Grade
    12·1 answer
  • Andrew’s Complete Cameras offers its customers an interactive website to help them choose the best camera for their lifestyle. B
    8·1 answer
  • What is the long tube on a microscope called​
    15·1 answer
  • Create a public class Dog that stores a single double age set by the constructor. (Reject negative ages using assert.) Dog shoul
    13·1 answer
  • Dates of birth were entered into a computer program . The data was stored in the format DAY/MONTH/YEAR.The program rejected this
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!