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
Imagine an everyday scenario in which you are using the internet: downloading a file, uploading a photo, checking your email, et
ad-work [718]

Imagine an everyday scenario in which you are using the internet: downloading a file, uploading a photo, checking your email, etc then TCP and UDP vacation spot port numbers are dynamically generated with the aid of using the sending tool that allows you to music the responses to requests.

<h3>Which TCP IP software layer protocol is generally used to map IP addresses to the Web pages?</h3>

FTP (File Transfer Protocol) It is one of the extensively used software layer protocols of the TCP/IP protocol suite. FTP is largely used to change facts among host gadgets over the Internet or Intranet securely.

TCP and UDP vacation spot port numbers are dynamically generated with the aid of using the sending tool that allows you to music the responses to requests. TCP mechanisms retransmit facts while an acknowledgment isn't always acquired from the vacation spot device inside a hard and fast duration of time,.

Read more about the L2TP:

brainly.com/question/15327815

#SPJ1

3 0
2 years ago
Write the icon of full justification​
ad-work [718]

Answer:

In the paragraph group, click the Dialog box Launcher. ,and select the Alignment drop - down menu to set your justified text. You can also use the keyboard shortcut , Ctrl + J to justify your text

6 0
2 years ago
Senior executives at a global manufacturing company are determining the key performance indicators they'll use to judge how effe
ella [17]

Answer:

Campaign metrics.

Explanation:

Senior executives at such a multinational packaging corporation are defining primary success metrics that they can use to determine the efficacy of certain web video advertising promotions on Google Ads.

A Campaign Metrics Standards are being established because it is the Marketing Metrics which provide quantifiable values utilized by communication managers to illustrate the success of initiatives through all communication platforms.

8 0
3 years ago
Select one of the wrong answer from question 1 and explain why it is ironic.
matrenka [14]
There are no questions
3 0
3 years ago
. Write programming code in C++ for school-based grading system
AleksAgata [21]

Explanation:

The grade must be calculated based on following pattern:

Average Mark RangeGrade91-100A181-90A271-80B161-70B251-60C141-50C233-40D21-32E10-20E2

Calculate Grade of Student in C++

To calculate grade of a student on the basis of total marks in C++ programming, you have to ask from user to enter marks obtained in 5 subjects. Now add marks of all the 5 subjects and divide it by 5 to get average mark. And based on this average mark, find grade as per the table given above:

// C++ Program to Find Grade of Student // -------codescracker.com------- #include<iostream> using namespace std; int main() { int i; float mark, sum=0, avg; cout<<"Enter Marks obtained in 5 Subjects: "; for(i=0; i<5; i++)

6 0
3 years ago
Other questions:
  • Which of these is a weakness of written communication?
    8·1 answer
  • GAMES Which is better Roblox or BattleCamp Basically Free Points But Please Answer
    7·2 answers
  • Given an array arr of type int , along withtwo int variables i and j , write some code thatswaps the values of arr[i] and arr[j]
    6·1 answer
  • Normal wear and road conditions can take their toll on a car’s steering and suspension system, altering __________. A. wheel ali
    15·2 answers
  • Which statement assigns the value 140 to the variable streetNumber in Python?
    13·1 answer
  • A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor.
    14·1 answer
  • A customer wants to increase his storage capacity by 25gb
    7·1 answer
  • Which option is typically only used when utilizing self joins?
    8·1 answer
  • If a TextView has not been displayed yet, it is possible to retrieve measurements about its width and height using the _________
    7·1 answer
  • In cell b12 create a formula using max f7nction to calculate maximum value in B4:B9
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!