"Unlonely nights, romantic moments" *kidding*
Just a quick note directed to a particular firstyear who says he is engaging problems concerning the CAPITALIZATION OF LETTERS (and the reverse of it).
But before that let me just say that We all feel pleased about your eagerness to do programming stuff. We commend you for that and do continue keeping on. Cheers!
Ok, moving on, there is such a thing in C++ programming called TYPECASTING (a roughly similar JAVA tool is PARSING) that allows you to force a declared variable into a data type you desire at Run time. To address the question on capitalizing your letters, think of it as
- forcing the input lowercase letter to be a number
- to which you will add a value
- where that value, when converted back to a letter
- will output its corresponding Uppercase equivalent.
IMPORTANT: the ascii set is the link between your lowercase and uppercase letters.
take this code fragment for instance,
char sampleLetter = 'j';
int sampleLetterBecomesInt = (int)sampleLetter; //typecasting happens here
sampleLetterBecomesInt = sampleLetterBecomesInt - 32;
cout << (char)sampleLetterBecomesInt; //and here
Once your done, you're ready for exercises. If you've followed the article on strings (older posts) then you are already equipped with necessary logic to do the following.
- given a string variable with the value of "your_name"(i mean really your name as in Jessa or Martin) written in lowercase, Traverse the string capitalizing the first letter of your name.
- then you may try the reverse
- then you may try CamelCaps in compound words
- or do it in regular intervals
// odds become capital evens are retained
0 <- post your comments here:
Post a Comment