Sale!

COP3223C Small Program 7 Solved

Original price was: $35.00.Current price is: $30.00.

Download Details:

  • Name: smallprogram7-qnv7ma.zip
  • Type: zip
  • Size: 148.80 KB

Category:

Description

5/5 - (1 vote)

Problem 1

Write a user defined function called deblank that takes a string phrase output and a string
phrase input argument and copies the input argument with all blanks removed and stores the
result in the output string. Blanks are the white spaces in a string.

For this problem, declare the
strings of size 20 and ask the user to input one to store. Display the output result in the main
function. The following figure shows a sample output in the terminal.
Figure 3: Sample output for problem 1. Make sure it matches for the python script.

Problem 2

Write a user defined function called pluralize that takes a noun as a string input and will
pluralize the word. The result should be displayed in the main function. Note the following rules
about noun plurals:
a) If noun ends in “y”, remove the “y” and add “ies”.
b) If noun ends in “s”, “ch”, or “sh”, add “es”.
c) In all other cases, just add “s”.

For this problem, declare a string of size 20 and ask the user to input one. The following figure
shows a sample output in the terminal.
Figure 4: Sample output for problem 2. Make sure it matches for the python script.
Small Program 7 Page 4

Problem 3

Write a user defined function called fact that takes a one word string as input and determines
how many letters, digits, and punctuation characters it contains. The results should be displayed
in the user defined function.

For this problem, declare a string of size 20 and ask the user to
input one. The following figure shows a sample output in the terminal.
Figure 5: Sample output for problem 3. Make sure it matches for the python script.

Problem 4

Write a user-defined function called substring that takes two strings as arguments. If the
second string (in the argument) is contained, the memory address at which the contained string
begins is returned. For example, substring(“turkey”, “key”) would return the memory address
of the k in “turkey”.

Otherwise return a NULL pointer. In the main function, ask the user
for the two strings. Once the strings are entered, call the user defined function. Once the
function has returned a resulting value, display message of the result. For example substring(“turkey”, “key”) would cause the message “Substring key exists!” to
be displayed.

The function call substring(“store”, “too”) would cause the message
”Substring too doesn’t exist!” to be displayed. Note: The strings are only single
words. Do not worry about sentences!

You cannot use the built in strstr() function to
solve this problem or any built in memory function! Using any of these functions will
result in a score of 0 for this question. You can assume that the first string argument is
always bigger than the second string argument.

For this problem, declare a string of size
20 and ask the user to input one. The following figure shows a sample output in the terminal.
Super Big Hint: Your function is going to return an address type value, think about how your
user defined function header would look.

You should have notice something during lectures.
Figure 6: Two sample outputs for problem 4 when the substring exists and doesn’t exists. Make
sure it matches for the python script.
Small Program 7 Page 5