0% found this document useful (0 votes)
3 views

Lab 4.1

Uploaded by

ellie71315
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab 4.1

Uploaded by

ellie71315
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Robert J Seedorf- CS&P

Gabriella Pagano 10/26/2022

Lab 4.1
After answering each of the questions be sure to capture the output of one
execution of your program to a text file / word doc. Also, be sure to save a copy of
your code, you may
need a functioning version to answer one of the subsequent questions.

1) Write a function named printN that takes an int n, a string s, and returns
void. This function must print the string s, n times.

2) Write a function called multTable that returns void, takes in an int row and,
int col and prints the multiplication table from 1 up to the two integers.
For example, a call to this function like... multTable(3, 5) prints…

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15

Extra credit: print the output as neatly as possible. When attempting this
think about the way we handle numbers greater than 10, what about greater
than 100? The goal is to keep everything in neat rows and columns so the
spacing between entries makes them clear. In the example above, 10, 12
and 15 offset the columns so they are not neatly spaced. To answer this
question you must solve this problem for any given m and n. This requires a
separate solution from the main question.

3) Write a function called smallestLetter that takes in a string argument and


returns a char. The char that is returned by this function is the character in
the string with the lowest ASCII integer code.
For example: smallestLetter("Hello") returns ‘H’ which is
code 72, and smallestLetter("Hello World") returns ‘ ’ (The space
character) which is code 32

4) Write a function called shorten that takes in one string and returns a
string. The string that is returned is the same string that was entered, but
without vowels.
For example: shorten("Hello World!") returns “H ll W rld!”
(notice the e and o's were all dropped. TIP: be thorough with your
testing)

5) Write a function named intersection that takes in two strings named s1


and s2 and returns a string. This function will find all the characters that
exist in BOTH s1 and s2 and return all of them as a string.

6) EXTRA CREDIT: Write a function named difference that takes in two


strings named str1 and str2 and returns a string. This function will find
all the characters that exist in str1 and that ARE NOT in str2 and return all
of them as a string. (TIP, start with your answer to question 5 and go from
there)

You might also like