Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following C program asks the user for two input null-terminated strings, each stored in uninitialized 100-byte buffer, and compares them. The program then shows
The following C program asks the user for two input null-terminated strings, each stored in uninitialized 100-byte buffer, and compares them. The program then shows the alphabetical order of both strings, by reporting whether the first is less than the second, the second is less than the first, or both are equal.
Write a full MIPS program that provides the exact same output as the reference C code, including all messages shown to the user.
#include stdioh> int main() // Two strings, 100 bytes allocated for each char si [100; char s2 [100]; // Read string 1 printf("Enter string scanf("%s", s1); 1: "); // Read string 2 printf("Enter string scanf("%s", s2); 2: "); // 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 ") break; // Current character is greater for s2 if (c1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started