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
What is the purpose of a title slide on power point
ArbitrLikvidat [17]
It would be D because whenever there is a title slide, you get an idea of what you are talking about

8 0
4 years ago
Read 2 more answers
The architecture that the large paper company Mohawk adopted enables the company to scale technology services up and down instan
arlik [135]

Answer: (C) Service-oriented

Explanation:

 The service-oriented architecture is the one of the type of software design which provide various types of service and application over the network by using different type of communication protocols.

  • The service oriented architecture is basically based on the distributed computing on the different types of platform.

 This architecture design is mainly based upon the reply and request service from client to the server and vice versa. The service oriented architecture works on the basic principle is that the technology and the products should be independent.

Therefore, Option (C) is correct.

6 0
3 years ago
Is anyone else experiencing the wording::nonifacation::glitch about the "5 hours ago" thingy to whenever you answer a question o
sineoko [7]
I was unable to click on any of my notifications but that got fixed on its own a day later. 
5 0
3 years ago
Read 2 more answers
Which option correctly describes a DBMS application? A. software used to manage databases B. software used to organize files and
ahrayia [7]
The answer is A.
It's a software used to manage databases


DBMS stands for DataBase Management System
4 0
3 years ago
Read 2 more answers
Draw a circuit with a 12-volt battery, a 100 ohms resistor in series, and two resistors (each of value 200 ohms) in parallel. Wh
amid [387]

Answer:

200 Ω

Explanation:

Hi there!

Please see below for the circuit diagram.

<u>1) Find the total resistance of the resistors in parallel</u>

Total resistance in parallel equation: \frac{1}{R_T} = \frac{1}{R_1} +\frac{1}{R_2}

Both the resistors measure 200 Ω. Plug these into the equation as R₁ and R₂:

\frac{1}{R_T} = \frac{1}{200} +\frac{1}{200}\\\frac{1}{R_T} = \frac{1}{100}\\R_T=100

Therefore, the total resistance of the resistors in parallel is 100 Ω.

<u>2) Find the total resistance of the circuit</u>

Now, to find the total resistance of the circuit, we must add the 100 Ω we just solved for and the 100 Ω for the other resistor placed in series:

100 Ω + 100 Ω = 200 Ω

Therefore, the total resistance of the circuit is 200 Ω.

I hope this helps!

7 0
3 years ago
Other questions:
  • Which statement best describes antivirus software
    12·2 answers
  • If the current through a heater coil is 5 amp and the supply voltage is 120 volts, the coil resistance is A. 0.04 ohm. B. 24 ohm
    6·1 answer
  • An example of an email client is:<br> A.)Yahoo<br> B.)Gmail<br> C.)Outlook<br> D.)All of the Above
    9·1 answer
  • The code segmentif (speed &lt;= 40)cout &lt;&lt; "Too slow";if (speed &gt; 40 &amp;&amp; speed &lt;= 55)cout &lt;&lt; "Good spee
    11·1 answer
  • Write a program in C++ or C that includes two different enumeration types and has a significant number of operations using the e
    15·1 answer
  • How do you think computers have helped improve documentation, support and services within the healthcare industry
    13·1 answer
  • Here is a list of storage devices:
    5·1 answer
  • What is problem scoping
    14·1 answer
  • A good information that contains the facts necessary for decision makers to solve a problem is characterized by the __________.
    15·2 answers
  • How to do or create a shepard tone using additive synthesis in Pure Data. Please help, desperate!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!