Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prompt the user and read in a string. Make your string large enough to hold 100 characters. 2. Count the number of words in the

Prompt the user and read in a string. Make your string large enough to hold 100 characters.

2. Count the number of words in the string. A word is one or more non-blank characters separated by one or more blanks. My suggestion is to use a flag (a boolean variable) to indicate whether or not you are in a word. Then you know you have found a word when the flag indicates that you are in a word and the next character is a blank. Think about how you will know when you have found the end of a word, and what you should do with your flag at that point.

3. Create a new string which is a copy of the original string, except that the new string is converted to uppercase. All non-letter characters should be unchanged. Convert the letters using difference between the ASCII codes for capital letters and the ASCII codes for small letters. Do not create nested if processing.

4. Print the original string, the new string, and the word count. Make sure you print messages to label your output.

When we call syscall to read in a string, we give a length n in $a1. syscall reads in at most n-1 characters and it adds a null byte (which has the value Oxo) to the end of the string. If the string is less than n-1 characters, then syscall adds a newline (which has the value Oxa) after the null byte. This means that the last word can end with either a blank, the null byte, or a newline. However, since the newline is always followed by the null byte, you can ignore the newline. But you will need to look for the null byte since there may not be a blank after the last word.

Written in MIPS

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

2. What is the business value of security and control?

Answered: 1 week ago