Answer to Question #326371 in C++ for etonalang

Question #326371

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.


1
Expert's answer
2022-04-10T05:24:15-0400
#include <iostream>
using namespace std;


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


    cin >> ch;
    if (ch != 'c' && ch != 'C')
        correct = false;
    cin >> ch;
    if (ch != 'o' && ch != 'O')
        correct = false;
    cin >> ch;
    if (ch != 'd' && ch != 'D')
        correct = false;
    cin >> ch;
    if (ch != 'y' && ch != 'Y')
        correct = false;
    
    if (correct)
        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