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
A class named clock has two instance variables : hours (type int ) and isticking (type boolean ). write a constructor that takes
Leno4ka [110]
<span>I guess you need it written in Java. So if you need only constructor, then here it is:
public Clock(Clock clock1) {
          this.hours = clock1.hours;
          this.isTicking = clock1.isTicking;
}

This code is 100% correct</span>
3 0
3 years ago
Two ways of selecting text with mouse​
AVprozaik [17]

Answer:

hold down left click and drag or double/triple click the text

Explanation:

4 0
2 years ago
Which of the following CSS rules will select the HTML element with the id logo and set the font size for that element to 60 pixe
Aleksandr [31]

The CSS rules that can select the HTML element with the id logo and set the font size for that element to 60 pixels is #logo {font-size: 60px.

<h3>What are HTML elements?</h3>

The <html> element is known to be the background or root element and it is one that tells more about the whole HTML document.

Note that in the above scenario, the option that will select the HTML element with the id logo and set the font size for that element to 60 pixels is #logo {font-size: 60px.This is because it will give the accurate form of what it is about.

Learn more about  HTML element  fromhttps://brainly.com/question/13164785

6 0
2 years ago
. The limitingcondition for a list might be the number of elements in thelist.
kompoz [17]

Answer:

True

Explanation:

Yes, the limiting condition of a linked list is the number of the elements that are present in the list. Consider a linked list contains  'n' number of elements, create an iterator which iterates over all the n elements of the linked list. So , in the limiting condition ( for loops , while loops, do while loops in all the looping conditions in fact in any conditions ) the iterator has to iterate over all the elements present in the linked list. So , the limiting condition is the number of elements in the list.  

4 0
3 years ago
What is the code for command prompt?
Anna35 [415]
The code is batch also know as .bat to make a "hello world" program you would simply put:
@echo off ##this turns off c:/ ect..
Echo Hello World ##displays Hello World
Pause ##Pauses the program until you press a button
8 0
3 years ago
Other questions:
  • Press ____ to select the entire worksheet.<br> F1<br> F4<br> ALT+A<br> CTRL+A
    8·1 answer
  • Word processing programs have different view options that you can use depending on the tasks you’re performing. Which option hel
    11·1 answer
  • Marcus just created a new folder specifically for his buisness records so he would like to move last months business transaction
    13·2 answers
  • How to remove duplicates from list in python?
    8·2 answers
  • Multiply 1101 and 0110 in binary.
    10·1 answer
  • If an individual receives 1.8 mGy while standing 4 ft from a source of radiation for 2 minutes, which of the following option(s)
    9·1 answer
  • 6. At age 17, what was Minhaj's definition of the American Dream?
    8·1 answer
  • Wap in java to complete the following (16*1) +(14*2) +(12*3) +(10*4) +(8*5) +(6*6) +(4*7)​
    13·1 answer
  • Felicity wants to capture the attention of the regular subway commuters in her area though her print advertisements​
    13·1 answer
  • Eric would like to have a callout text box that makes it look as if the character in an image is speaking. Which object should h
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!