List of all available Websheets
Viewing cpp/cstrings/capitalize by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Define a function <tt>capitalize</tt> that takes a C string and capitalizes every letter in it. Non-letters should be left alone. <p>You may need to refer to an ASCII table:<br> <img src="http://macao.communications.museum/images/exhibits/2_18_8_1_eng.png">. <p>You should <b>not</b> use cin or cout, that part is done for you in order to facilitate testing. |
Public permissions | |
Engine | |
Template / Reference solution |
using namespace std; void capitalize(char text[]) { \[ int i=0; while (text[i] != '\0') { if (text[i] >= 'a' && text[i] <= 'z') { text[i] += 'A'-'a'; } i++; } ]\ } int main() { char word[81]; // allow a word up to 80 characters cin >> word; cout << "Before calling your function, word is: " << word << endl; // call YOUR function capitalize(word); cout << "After calling your function, word is: " << word << endl; return 0; } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [ {"stdin": "thisISaTEsT"}, {"stdin": "don't_4get_ONLY_letters_CHANGE"}, {"stdin": "abcsdmZklAdz][`'@{}"} ] |
Solution visibility |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.