Question

Using High Assembly language Write a program to produce a number table as described here. This...

Using High Assembly language Write a program to produce a number table as described here. This table should be built from a single integer value provided by the user. The program will display a square 5X5 of various numbers. The entered number should appear in an X like pattern across the table, diagonally across the table. Every other spot besides the X pattern should be filled with a number. Those excess numbers should start with one bigger than the entered number and increment by one for every additional excess number used.

For example, the following output should be produced when the user inputs the starting value 15:

Gimme a starting value: 15
15 16 17 18 15
19 15 20 15 21
22 23 15 24 25
26 15 27 15 28
15 29 30 31 15
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below C++(High Assembly Language) program will produce the required pattern.

Program starts;

#include<iostream>
#define GRID_SIZE 5
using namespace std;

int main(){

int x,current_value,i,j;
cout<<"gimme a number: ";
cin>>x;
cout<<endl;

//Upper half Grid
for(int i=0 ; i<GRID_SIZE/2 ; i++){
   current_value = x + i*(GRID_SIZE-2) + 1;
   for(j=0 ; j<i ; j++){
       cout<<current_value++<<" ";
   }  
   cout<<x<<" ";  
   for(j=i+1 ; j<GRID_SIZE-1-i ; j++){
       cout<<current_value++<<" ";
   }  
   cout<<x<<" ";  
   for(j=GRID_SIZE-i ; j<GRID_SIZE ; j++){
       cout<<current_value++<<" ";
   }  
   cout<<endl;
}

//Lower half Grid
for(int i=GRID_SIZE/2 ; i<GRID_SIZE ; i++){
   current_value = x + i*(GRID_SIZE-2) + 1;
   for(j=0 ; j<GRID_SIZE-i-1 ; j++){
       cout<<current_value++<<" ";
   }
   cout<<x<<" ";  
   for(j=GRID_SIZE-i ; j<i ; j++){
       cout<<current_value++<<" ";
   }
      
   if(GRID_SIZE%2==0 || i!=GRID_SIZE/2) {
   cout<<x<<" ";
}
  
   for(j=i+1 ; j<GRID_SIZE ; j++){
       cout<<current_value++<<" ";
   }
   cout<<endl;
}
   return 4;
}

Here is the Screenshot of output of the above program.

Here is the Screenshot of code.

Add a comment
Know the answer?
Add Answer to:
Using High Assembly language Write a program to produce a number table as described here. This...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT