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

Write a mips assembly language program that allows the user to enter two strings

ID: 3756640 • Letter: W

Question

Write a mips assembly language program that allows the user to enter two strings. Have the program determine whether the second string is a substring of the first. If it is infact a substring of the first string, print out the index location of where it begins in the first string. For example:

string #1: lamp shade

string #2: sh

Resulting output: 5

As 5 is the index location as to where the substring starts in the first string. If the second string is not a substring of the first, make the resulting output -1. The -1 will inform the user that it's not a substring of the first.

Explanation / Answer

#include<stdio.h>

void main()
{
char strn[80], searchh[10];
int count_1 = 0, count_2 = 0, x, y, flg;

printf("Enter a string:");
gets(strn);
printf("Enter searchh substring:");
gets(searchh);
while (strn[count_1] != '')
count_1++;
while (searchh[count_2] != '')
count_2++;
for (x = 0; x <= count_1 - count_2; x++)
{
for (y = x; y < x + count_2; y++)
{
flg = 1;
if (strn[y] != searchh[y - x])
{
flg = 0;
break;
}
}
if (flg == 1)
break;
}
if (flg == 1)
printf("SEARCH SUCCESSFUL!");
else
printf("SEARCH UNSUCCESSFUL!");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote