Answer to Question #258526 in C++ for yan

Question #258526

Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong".


1
Expert's answer
2021-10-29T03:59:10-0400
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main() {
    string name;
    string ch;

    for (int i=0; i<4; i++) {
        cin >> ch;
        name += tolower(ch[0]);
    }
    if (name == "cody") {
        cout << "Correct" << endl;
    }
    else {
        cout << "Wrong" << 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
APPROVED BY CLIENTS