title: Magic square calculation 2 dimensional array C++
body: <p>So I need to make a code with these functions. the checkMatrix has to be a boolean and the getData has to pass the 1D array. How do I check the magic square with a 2D array?  instructions :Write a program that will prompt the user for the integers to fill a 3 x 3 two dimensional array
  that builds a table. Once the data is entered the program checks to
  see if the table forms a magic square. When complete have the program prompt the user to see
  if they want to test another square and loop back accordingly. Note: Your solution should
  validate the input to the program from erroneous input. This means that your program checks
  to see that the data entered is numeric and in the range of 1 and 9 inclusive and not duplicate
  data can be entered. Hint: A one dimensional array could be used to keep a tally of which
  numbers have been assigned to the magic square.
  Program Style=
  The program must contain the following functions that carry out the operations in the given
  descriptions. Use the function names given. All data must be passed to required
  functions by value or reference; no global variables are allowed.
  Function Description=
  main= This function explains the magic square directions, organizes calls to
  other functions, and reports final result.
  getData= This function gets and validates the 9 digits entered by the user to fill
  the 3 x 3 table. Must implement passing of array data.
  checkMatrix=
  This function is passed the array data matrix entered by the user
  determine if it is a magic square sequence and returns a Boolean as
  result of test.</p>
  
  <pre><code>            #include &lt;iostream&gt;
              #include &lt;windows.h&gt;
  
              using namespace std;
  
              int checkMatrix()
              int getData(input[9] );
              //prototypes
  
              int main()
              {
                      char repeat;
                      //declaration of variables
                  do
                  {
                      system("cls");
                      //clear screen between calculations
  
                      cout &lt;&lt; "**********************************************************" &lt;&lt; endl;
                      cout &lt;&lt; "**         CSC 175 Program #6 by Morgan Kelly           **" &lt;&lt; endl;
                      cout &lt;&lt; "**                                                      **" &lt;&lt; endl;
                      cout &lt;&lt; "**  Enter a magic square sequence by assigning a value  **" &lt;&lt; endl;
                      cout &lt;&lt; "**  from 1 to 9 to each location of a 3 by 3 table.     **" &lt;&lt; endl;                                                                **" &lt;&lt; endl;
                      cout &lt;&lt; "**********************************************************" &lt;&lt; endl;
                      //header
  
  
  
  
                      getData(input[9]);
                      //call getData function
  
                      cout &lt;&lt; "*************" &lt;&lt; endl;
                      cout &lt;&lt; "*" &lt;&lt; input[0] &lt;&lt; " " &lt;&lt; input[1] &lt;&lt; " " input [2] &lt;&lt; "*" &lt;&lt; endl;
                      cout &lt;&lt; "*" &lt;&lt; input[3] &lt;&lt; " " &lt;&lt; input[4] &lt;&lt; " " input [5] &lt;&lt; "*" &lt;&lt; endl;
                      cout &lt;&lt; "*" &lt;&lt; input[6] &lt;&lt; " " &lt;&lt; input[7] &lt;&lt; " " input [8] &lt;&lt; "*" &lt;&lt; endl;
                      cout &lt;&lt; "*************" &lt;&lt; endl;
  
                      if checkMatrix()= true
                          cout &lt;&lt; "This is a magic square!" &lt;&lt; endl;  
                      else
                          cout &lt;&lt; "This is not a magic square!" &lt;&lt;endl;
  
                      cout &lt;&lt; "Want to check another table? (y/n): ";
                      cin &gt;&gt; repeat;
  
                  } while (repeat == 'y' or repeat == 'Y');
                  //repeat program and be able to calculate another table
  
                  return 0;
              }
  
  
               int getData(input[9])
              {
                  int input[9];
                  //declaration of 1 dimensional array
  
                  while (input[9] &gt;0 and input[9]&lt;10)
                  {
                      cout &lt;&lt; "Enter row 1 and column 1: ";
                      cin &gt;&gt; input[0];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 1 and column 2: ";
                      cin &gt;&gt; input[1];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 1 and column 3: ";
                      cin &gt;&gt; input[2];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 2 and column 1: ";
                      cin &gt;&gt; input[3];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 2 and column 2: ";
                      cin &gt;&gt; input[4];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 2 and column 3: ";
                      cin &gt;&gt; input[5];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 3 and column 1: ";
                      cin &gt;&gt; input[6];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 3 and column 2: ";
                      cin &gt;&gt; input[7];
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "Enter row 3 and column 3: ";
                      cin &gt;&gt; input[8];
                      cout &lt;&lt; endl;
                  }
                  if cin.fail()
                  cin.clear();
                  cin.sync();
                  cout &lt;&lt; "INVALID INPUT - ";
                  //validates for input(numbers) that are between 1 and 9 only
  
                  //input numbers from user and validate
  
                   return input[9];     
              }
  
  
              bool checkMatrix()
              {
                 if array1[]=array2[]
                  {return true;}
                 else
                 {return false;}  
              }
  </code></pre>