Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write neatly and if you don\'t mind explain the answer. Thanks in advance

ID: 3868376 • Letter: P

Question

Please write neatly and if you don't mind explain the answer. Thanks in advance!!

Write an SRC subroutine that copies a null-terminated source string to a location in memory backwards, creating a second null-terminated string. For example, if the original string was "Exam", the new string should be "maxE". Your subroutine should accept its argument, a pointer to the source string, in Register r0: and a pointer to the destination memory in Register r1. Your subroutine should adhere to the coding convention as used in class. a. Develop a STEP-BY-STEP algorithm for the subroutine in the right side of the table below. b. Write the SRC instructions that implement your algorithm in the left side of the table below. Note that you may want to (but you don't have to) make use of the string length subroutine developed in class. If you choose to use it, you may just call it from your code, assuming that it accepts its argument in Register r0, and returns its result in Register r4.

Explanation / Answer

#include // Needed to use IO functions int main() { int sumOdd = 0; // For accumulating odd numbers, init to 0 int sumEven = 0; // For accumulating even numbers, init to 0 int upperbound; // Sum from 1 to this upperbound int absDiff; // The absolute difference between the two sums // Prompt user for an upperbound printf("Enter the upperbound: "); scanf("%d", &upperbound); // Use %d to read an int // Use a while-loop to repeatedly add 1, 2, 3,..., to the upperbound int number = 1; while (number sumEven) { absDiff = sumOdd - sumEven; } else { absDiff = sumEven - sumOdd; } // Print the results printf("The sum of odd numbers is %d. ", sumOdd); printf("The sum of even numbers is %d. ", sumEven); printf("The absolute difference is %d. ", absDiff); return 0; }