Write a function which converts an uppercase letter 'A'{'Z' to the corresponding lowercase
letter. If the parameter is not a letter it must be returned unchanged. Write a main program
which calls the function.
#include <iostream>
using namespace std;
char uppercase(char ch) {
if (ch >= 'A' && ch <= 'Z')
ch -= 'A' - 'a';
return ch;
}
int main(int argc, char* argv[]) {
if (argc < 2) {
cout << "An argument is missing" << endl;
return 1;
}
for (char* p = argv[1]; *p != 0; p++) {
cout << uppercase(*p);
}
cout << endl;
return 0;
}
Comments
Leave a comment