Answer to Question #161241 in C++ for Ashes

Question #161241

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. 


1
Expert's answer
2021-02-10T10:31:57-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog