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
#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");
}
}
Comments
Leave a comment