Answer to Question #310581 in C++ for Secret Agent

Question #310581

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".


It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct.


Now, will you take on this task?


Input

A line containing four one-letter strings separated by a space.

c·O·D·y

Output

A line containing a string.

Correct




1
Expert's answer
2022-03-13T03:33:23-0400
#include <iostream>
#include <cctype>
using namespace std;


int main() {
    char* cody = "cody";
    char ch;
    bool correct = true;


    for (int i=0; i<4; i++) {
        cin >> ch;
        if (tolower(ch) != cody[i]) {
            correct = false;
        }
    }

    if (correct) {
        cout << "Correct";
    }
    else {
        cout << "Wrong";
    }
    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