SPELL BEE CONTEST Given a pair of words (the first is the correct spelling and the second is the contestant’s spelling of the word) determine if the word is spelt correctly. The degree of correctness is as follows: CORRECT if it is an exact match ALMOST CORRECT if no more than 2 letters are wrong WRONG if 3 or more letters are wrong

 Given a pair of words (the first is the correct spelling and the second is the contestant’s spelling of the word) determine if the word is spelt correctly.

The degree of correctness is as follows:

  • "CORRECT" if it is an exact match
  • "ALMOST CORRECT" if no more than 2 letters are wrong
  • "WRONG" if 3 or more letters are wrong
 EX:
enter the first word
WORD
enter the second word
WORD

OUTPUT:
WORD IS CORRECT

PROGRAM:

#include <stdio.h>
int main()
{
    char a[10];
    char b[10];
    int value=0,i=0;
    printf("enter the first word");
    scanf("%s",a);
    printf("enter the second word");
    scanf("%s",b);
    while(a[i]!='\0'&&b[i]!='\0')
    {
        if(a[i]!=b[i])
        {
            value++;
        }
            i++;
    }
    if(value==0)
    printf("%s IS CORRECT",b);
    else if(value<=2)
    printf("%s IS ALMOST CORRECT",b);
    else
    printf("%s IS WRONG",b);
    return 0;
}




PREVIOUS PROGRAM CLICK HERE TO COMPILE

                               LEARN  WITH JAGADEESH
                                  copyright© to jagadeesh

Post a Comment