Answer to Question #303839 in C for Thank you!

Question #303839

Input three characters in three different lines.

Print out "Equal" if all of the characters are equal. Otherwise, print out "Not Equal". Note, however, that in C language, uppercase and lowercase letters are not equal.


Enter·the·first·character:·C

Enter·the·second·character:·c

Enter·the·third·character:·C

Not·Equal



1
Expert's answer
2022-02-28T08:30:13-0500
#include <stdio.h>

int main()
{
    char char1;
    char char2;
    char char3;
    
    printf("Enter the first character: ");
    scanf("%c", &char1);
    getchar();
    printf("Enter the second character: ");
    scanf("%c", &char2);
    getchar();
    printf("Enter the third character: ");
    scanf("%c", &char3);
    getchar();
    if ((char1 == char2) && (char2 == char3))
    {
        printf("Equal");
    }
    else
    {
        printf("Not equal");
    }
}

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