4. Is It You, Cody?
by CodeChum Admin
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
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
char ch1,ch2,ch3,ch4;
scanf("%c %c %c %c",&ch1,&ch2,&ch3,&ch4);
if(tolower(ch1)=='c' && tolower(ch2)=='o' && tolower(ch3)=='d' && tolower(ch4)=='y'){
printf("Correct\n\n");
}else{
printf("Wrong\n\n");
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment