Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 6 (27 points) Your goal in this problem is to write a C program, called strings.c, that performs some simple string analysis and manipulation.

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Problem 6 (27 points) Your goal in this problem is to write a C program, called strings.c, that performs some simple string analysis and manipulation. To help you write this program, the relevant part of the ASCII code table is given below. As you can see, the ASCII codes of the upper-case letters A to Z are in sequence from 65 to 90, respectively. The ASClII codes of the lower-case letters a to z are also in sequence from 97 to 122, respectively character | A B C XYZ [ \] ^-abc x y z ASCII code 65 66 6788 89 90 91 92 93 94 95 96 97 98 99120 121 122 The program strings.c first prompts the user to enter a string, consisting of a contiguous sequ- ence of letters. You should assume that the user complies and enters a string consisting of letters (upper-case A-Z or lower-case a-z or both) only, without whitespace between them. You should also assume that the user string will have at most MAXLEN-1 127 characters. The program then further prompts the user to enter a single letter. You should again assume that the user complies, and enters a single character which is either an upper-case letter [A-2] or a lower-case letter [a-z]. This letter may or may not occur in the user string. After that, the program reports to the user the length of the string the user has entered (the total num- ber of characters in it, not including the ' \0' character). The program also displays the user string with all letters converted to upper case and with all letters converted to lower case. The program then counts the number of times the single character entered by the user appears in the user string (note that this count is case-sensitive, e.g. the letters A and a are considered different). If this number is nonzero, the program reports it to the user, along with the list of positions where this character occurs. If the character does not occur at all in the user string, the program simply reports this to the user. Finally, the program counts how many different letters there are in the user string. For example, if the string is ThisisMyFavoriteCourse, then the total number of characters in the string (its length) is 22, but the number of different characters in this string is 14. Note that this count is case- insensitive. For example, in the string ThisIsMyFavoriteCourse, the letters T and t (as well as I and i) are considered the same. Here is a sample run of the program. /home/userXYZ/ECE15/Final> strings Enter a string [letters only]:ThisIsMyFavoriteCourse Enter a letter to find in your string: i The length of your string is 22 Your string in upper case: THISISMYFAVORITECOURSE Your string in lower case: thisismyfavoritecourse The letter i occurs 2 times in ThisisMyFavoriteCourse at the following positions: 3 14 The number of different letters in your string is 14 Provided on the next page is part of the source code that implements the programstrings.c. This part contains the forward function declarations, and the complete implementation of the function main (). Your task is to implement the other functions. Note that in this problem, you are nor allow- ed to use any functions from the C standard library, except for those declared in

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago