Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write the following Y86 assembley instructions for the following C code. Please write in text so I can copy and paste. * C Program

please write the following Y86 assembley instructions for the following C code. Please write in text so I can copy and paste.

 * C Program to Solve the Magic Squares Puzzle without using  
 * Recursion 
 */ 
#include  
 
void magicsq(int, int [][10]); 
 
int main( ) 
{ 
 int size; 
 int a[10][10]; 
 
 printf("Enter the size: "); 
 scanf("%d", &size); 
 if (size % 2 == 0) 
 { 
 printf("Magic square works for an odd numbered size "); 
 } 
 else 
 { 
 magicsq(size, a); 
 } 
 return 0; 
} 
 
void magicsq(int size, int a[][10]) 
{ 
 int sqr = size * size; 
 int i = 0, j = size / 2, k; 
 
 for (k = 1; k <= sqr; ++k) 
 { 
 a[i][j] = k; 
 i--; 
 j++; 
 
 if (k % size == 0) 
 { 
 i += 2; 
 --j; 
 } 
 else 
 { 
 if (j == size) 
 { 
 j -= size; 
 } 
 else if (i < 0) 
 { 
 i += size; 
 } 
 } 
 } 
 for (i = 0; i < size; i++) 
 { 
 for (j = 0; j < size; j++) 
 { 
 printf("%d ", a[i][j]); 
 } 
 printf(" "); 
 } 
 printf(" "); 
} 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions