The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Attached is a document that has 2 questions. Both deal with translating a C program into a MIPS assembly program. Please follow the instructions outlined in the document.
Â
Question 1The following C program asks the user for two input null-terminated strings, eachstored in uninitialized 100-byte buffer, and compares them. The program thenshows the alphabetical order of both strings, by reporting whether the first is lessthan the second, the second is less than the first, or both are equal.#include <stdio.h>int main(){ // Two strings, 100 bytes allocated for each char s1[100]; char s2[100]; // Read string 1 printf("Enter string 1: "); scanf("%s", s1); // Read string 2 printf("Enter string 2: "); scanf("%s", s2); // Compare them int index = 0; while (1) { // Load characters from s1 and s2 char c1 = s1[index]; char c2 = s2[index]; // Current character is greater for s1 if (c1 > c2) { printf("s1 > s2\n"); break; } // Current character is greater for s2 if (c1 < c2) { printf("s1 < s2\n"); break; }  // End of strings reached if (c1 == 0) { printf("The strings are equal\n"); break; } // Compare next character index++; }
Attachments: