Concept explainers
Lo Shu Magic Square C++
The Lo Shu Magic Square is a grid with 3 rows and 3 columns. The Lo Shu Magic Square has the following properties:
- The grid contains the numbers 1 through 9, each cell is unique.
- The sum of each row, each column, and each diagonal all add up to the same number.
Write a program that creates a 2D array of size 3x3, and fills each cell withn random, unique values betweem 1 and 9. Print the values. Determine if the 2D array is a Lo Shu Magic Square and print the results.
Sample Output
Run the program when the 2D array is a lo shu square.
A couple runs of the program where it is NOT a Lo Shu Magic Square.
|
|
---|---|
|
|
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 6 images
The program works good but for tis project the user is not allow to enter inputs. The program has to generate a random and unique number for every rows and columns.
Thank you.
The program works good but for tis project the user is not allow to enter inputs. The program has to generate a random and unique number for every rows and columns.
Thank you.
- Lw//. Two-Dimensional ArrayInstruction:Create a java program that generates elements (randomly from 10 – 75) of a 2-dimensional array (5x5) using the Random Class then perform the following:1) Output the array elements2) Output the sum of prime numbers in the array3) Output the elements in the main diagonal.4) Output the sum of the elements below the diagonal.5) Output the sum of the elements above the diagonal.6) Output the odd numbers below the diagonal.7) Output the even numbers above the diagonal. NOTE: Please do not use the array methods available on the internet. Use the for loop, while loop or do-while loop statement in your codes..arrow_forwardProgramming in C language.arrow_forwardIN C++ Write a method that lets you insert a number anywhere in an array that is already full. For instance, if you have an array of size 5: 3,6,1,2,0. You should be able to insert the number 9 in some desired/specified position. E.g 3,6,1,9,2,0.arrow_forward
- In C Programming Write a main function that declares an array of 100 ints. Fill the array with random values between 1 and 100. Calculate the average of the values in the array. Output the average.arrow_forwardC++arrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forward
- in C#, Visual Basic Write an app for Boston Airlines that allows a customer to reserve a seat on the airline’s only plane (capacity: 10 seats). Radio buttons should allow the choice between First Class and Economy. The app should then assign a seat in the first-class section (seats 1–5) or the economy section (seats 6–10). Use a one-dimensional array of type bool to represent the seating chart of the plane. Initialize all the elements of the array to false to indicate that all the seats are empty. As each seat is assigned, set the corresponding element of the array to true to indicate that the seat is no longer available. Your app should never assign a seat that has already been assigned. When the economy section is full, your app should ask the person if it is acceptable to be placed in the first-class section (and vice versa). If yes, make the appropriate seat assignment. If no, display the message “Next flight leaves in 3 hours."arrow_forwardIn C++ language, write a program to print "Junior" if the given array element starts with 'J' and print "Senior" if the array element starts with 's'. Print the name of the player and the message Junior" or "Senior" accordingly. string names [5] = {"J-Liam", "S-Naoh", "S-Elijah", "J-James", "S-Henry"};arrow_forwardJava program to check whether there is zero (0) value or -1 , if its there then display true otherwise false. Consider the output as follow:arrow_forward
- Wtite a java program that will accept 10 numbers and save it on array. After you input the 10 numbers, get and display the maximum and minimum value in array. Sample outputEnter 10 numbers:11233245162768398100 Maximum number: 100Minimum number: 4arrow_forwardQuestion 1 Write a program that declares an array of 100 doubles. The program asks the user to enter a number N between 100, and then: initializes the first N elements of the array to random numbers between 1 and 100. calculates the average of these numbers and displays it. A final loop displays the elements of the array, each on a line, with an indication as to whether that number is lower or higher than the average. For example, if the numbers generated are 5, 28, 3, 8, 15, 7, 22, 6, 1, 4, then the program will print: Average = 9.9 5 28 3 8 15 7 22 6 1 4 11 11 11 -- 11 11 1- —— 11 lower than average higher than average lower than average lower than average higher than average lower than average higher than average lower than average lower than average lower than averagearrow_forwardLab Activity for the students: Exercise 5: Write a program that asks the user to input 8 numbers and save them in a 2D array with 4 rows and 2 columns. The program finds the sum of all elements and prints the array in reverse order. (1 Mark ) Example : If the inputs are 12, 7, 23, 86, 40, 64, 97, 55. Then, the program will print: 55 97 64 40 86 23 7 12 Sum = 384arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education