Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Question:(Main issue is in bold, other parts is already coded)Write a C program that prints an n by n "magic square" (a square arrangement of the numbers 1, 2, ..., n2 in which the sums of the rows, columns, and diagonals are all the same). The user will specify the value of n.Store the magic square in a two dimensional array. Start by placing the number 1 in the middle of row 0. Place each of the remaining numbers 2, 3, ... , n2 by moving up one row and over one column. Any attempt to go outside the bounds of the array should "wrap around" to the opposite side of the array. For example, instead of storing the next number in row -1 (row negative 1), we would store it in row n - 1 (the last row). Instead of storing the next number in column n, we would store it in column 0. If a particular element is already occupied, put the number directly below the previously stored number.The magic square only needs to be up to 11 by 11 and can only be created from odd numbers.I want you to use functions for this project. I would like you to separately declare and define 3 separate functions. One for creating the magic square and putting it the two dimensional array.One for printing the magic square (for your printf, use 5 minimum field width).Finally, one for getting and returning the sum of the numbers in the magic square array.Take in input in the main function. If the input is an even number or is a number not between 1 and 11, exit the program. Also, print the value of the sum of magic numbers via the main function, since your function to calculate this should only be returning a integer.For the sum of all the numbers in the magic square array, I want you to use while loops. You can use either for loops or while loops for the print and create magic number functions.HINT: The only function that needs to return something is the sum magic square function (integer). The other two function don't need to return anything. C is a pass by value language, meaning that it typically can't change the values of arguments in functions. This doesn't apply to arrays because they are references (more in chapter 12). That means one argument in the functions should be a two dimensional array. You will be able to operate on this array.Sample I/O:Enter size of magic square: 3 8 1 6 3 5 7 4 9 2Sum of Magic Numbers: 45Enter size of magic square: 2Invalid Input: 2Enter size of magic square: 103Invalid Input: 103Enter size of magic square: 7 30 39 48 1 10 19 28 38 47 7 9 18 27 29 46 6 8 17 26 35 37 5 14 16 25 34 36 45 13 15 24 33 42 44 4 21 23 32 41 43 3 12 22 31 40 49 2 11 20Sum of Magic Numbers: 1225
Does each case in a switch statement terminate with a break? Is there a default case?
Develop a data representation for the current position of the ball. The position is best described with a pair of positive integers. Develop a data representation for velocity of the ball. You may assume that the ball always moves exactly 10 pixe..
Write a main program that illustrates the work of your functions. E.g., if a[ ]={1,2,3,3,4,5} then 3 occurs 2 times and 7 occurs 0 times.
Write a complete C++ program to report on the roots of a quadratic equation ax2 + bx + c = 0, a ≠ 0. compute the roots.
This lab, along with your TA, will help you navigate through designing, implementing, and testing a dynamic stack. Recall, a stack data structure is a restricted linked list, where only the top node in the stack may be accessed at any given time
Write a short program to simulate a ball being dropped off of a tower. To start, the user should be asked for the initial height of the tower in meters.
Create an object oriented solution that allows a customer to purchase between 1 and 3 pizzas, add toppings to each pizza, if desired, and then displays a receipt, including the details for each pizza, a pretax total amount, and a grand total amoun..
What are a class and a structure?
Many web sites make vigorous (over) use of many of the events in the dynamic HTML event model for marketing purposes. In some cases, one URL call may open 10 or more other Windows.
Call a function from main(), passing one value to it. Return TWO values, both the square of the number and the number to the power of three.
make a program to play lottery. The program randomly generates a Lottery of a three-digit number( any number from 100 to 999), prompts the user to enter a three-digit number, and determines
write a program in C++ to read an array of stored integers. Search for a value using binary search method. If the element is found, print its location else print element not found
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd