Question: 27. Translate the following C program to Pep/9 assembly language: #include int list[16]; int j, numItems; int temp; int main() { scanf(%d, &numItems); for (j
27. Translate the following C program to Pep/9 assembly language:
#include
int list[16];
int j, numItems;
int temp;
int main() {
scanf("%d", &numItems);
for (j = 0; j < numItems; j++) {
scanf("%d", &list[j]);
}
temp = list[0];
for (j = 0; j < numItems - 1; j++) {
list[j] = list[j + 1];
}
list[numItems - 1] = temp;
for (j = 0; j < numItems; j++) {
printf("%d ", list[j]);
}
printf("");
return 0;
}
Sample Input 5 11 22 33 44 55 Sample Output 22 33 44 55 11 The test in the second for loop is awkward to translate because of the arithmetic expression on the right side of the < operator. You can simplify the translation by transforming the test to the following mathematically equivalent test:
j + 1 < numItems;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
