Question: In at&t assmbly: Write a program that will collect some integers into an array and then rotate those elements in the array according to the
In at&t assmbly: Write a program that will collect some integers into an array and then rotate those elements
in the array according to the direction of the user. Heres a sample session:
Size of array:
Enter integers
Element :
Element :
Element :
Element :
Element :
Rotate LRE L
Rotate LRE l
Rotate LRE z
Try again. Rotate LRE R
Rotate LRE r
Rotate LRE E
Goodbye.
You will implement four procedures:
void getArrayint n int a will read n elements from the console and put them into the
specified array.
void printArrayint n int a will print the n elements of the array on a single line sepa
rated by commas.
void rotateLeftint n int a will rotate the array to the left one slot. An element in slot
i will be copied to slot i The element in slot will find itself in slot n
void rotateRightint n int a will rotate the array to the right one slot. An element in
slot i will be copied to slot i The element in slot n will find itself in slot
After filling the array, print the contents out and prompt for a rotation L or R or exit E Allow for
case insensitivity. L and l should both trigger a left rotation. Repeat this process until the user selects
exit.
Dont try writing this program all at once. First, implement printArray with a fixed array. Next,
implement leftRotate and test it on that array, printing the array before and after the rotate. Do
the same with rightRotate. At this point, implement getArray. Once your functions are ready, go
ahead and get the prompt loop working. Adding case insensitivity of the prompt response will be the
final step.
Save your program as rotate.s
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
