#include <iostream>
usingnamespace std;
constchar *lower = "abcdefghijklmnopqrstuvwxyz";
constchar *upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//=====================================================================
char myToUpper( char c )
{
for ( int i = 0; i < 26; i++ ) if ( lower[i] == c ) return upper[i];
return c;
}
//=====================================================================
char myToLower( char c )
{
for ( int i = 0; i < 26; i++ ) if ( upper[i] == c ) return lower[i];
return c;
}
//=====================================================================
int main()
{
for ( char c : "Manchester United 2013" ) cout << myToLower( c );
cout << '\n';
for ( char c : "Manchester City 2014" ) cout << myToUpper( c );
cout << '\n';
}
how to convert from uppercase to lowercase
The question looks deceptively simple, because it wouldn’t be so easy to write a general code which manages those languages where not all lowercase and uppercase letters have a one to one match or where diacritics are moved to a side of the letter when it becomes uppercase.
Luckily Latin alphabet doesn’t suffer from problems like those, but I think it would have been better to specify whether it was the only one to be dealt with or not.