Think Pair Share 15
- Due Oct 20, 2020 by 10am
- Points 1
- Submitting a file upload
- Available after Oct 19, 2020 at 10am
Think
Insert a new row just below the header in the table in your TPS Google Doc. Fill in the first two columns. Place your response to the following in the "Think" column:
Below is the code we wrote in TPS 14, in which we defined a function tolower to convert a string to its lower case version and return it. Now adjust the function so that it modifies the string variable passed in in-place (i.e., pass-by-reference) without returning anything. Once you do that, line 25 won't work anymore; why not?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#include <iostream> using namespace std; /** * Returns a copy of the given string with each character downcased. * * @param s The string to downcase. * @return A downcased version of s. */ string tolower(string s){ for(int i = 0; i < s.size(); i++){ s.at(i) = tolower(s.at(i)); } return s; } int main(){ string userInput; cout << "Enter a line of text to downcase:" << endl; getline(cin, userInput); cout << "Downcased version:" << endl; cout << tolower(userInput) << endl; return 0; } |
Pair
If you are joining the class live (in person or over Zoom), pair up with someone when asked to do so—please use Discord or your preferred means of interacting with someone to share your answers (please see the announcement with details about Discord). Settle on an answer between to two or three of you and put that answer down in your "Pair" column.
Share
Regardless of whether or not you are attending live, one person from your pair group should add your answer to the "TPS class share Links to an external site." document.
Submit
Finally, submit your personal TPS Google doc to this assignment.
Rubric
Criteria | Ratings | ||
---|---|---|---|
You uploaded your copy of the TPS Google doc
|
|
||
You made a reasonable attempt at the "thinking" portion and this was clearly marked on your document
|
|
||
You made a reasonable attempt at the "sharing" portion and this was clearly marked on your document
|
|
||
|