#include <iostream>
#include <cctype>
using namespace std;
void upercase(char[]);
void lowercase(char[]);
void reversecase(char[]);
int main()
{
char cstring[101];
int ans;
cout << "Enter a word or phrase up to 100 characters\n";
cin.getline(cstring, 101);
cout << "What do you want to do?\n";
cout << "\n\tConvert to uperecase (1)\n\tConvert to lowercase(2)\n\tReverse the case of each letter (3)\n\n";
cin >> ans;
switch (ans)
{
case 1: upercase(cstring); break;
case 2: lowercase(cstring); break;
case 3: reversecase(cstring); break;
}
cout << cstring;
cin.ignore();
cin.get();
return 0;
}
//---------------------------------------------------------------------------
void upercase(char word[])
{
int length=strlen(word);
for(int cnt=0; cnt<length; cnt++)
{
word[cnt]=toupper(word[cnt]);
}
}
void lowercase(char word[])
{
int length=strlen(word);
for(int cnt=0; cnt<length; cnt++)
{
word[cnt]=tolower(word[cnt]);
}
}
void reversecase(char word[])
{
int length=strlen(word);
for(int cnt=0; cnt<length; cnt++)
{
if(islower(word[cnt]))
word[cnt]=toupper(word[cnt]);
else if(isupper(word[cnt]))
word[cnt]=tolower(word[cnt]);
}
}