In these days kids are introduced to computers at a very early age and in some schools, the dictation test is conducted using computers. The teachers found it a bit difficult to evaluate these tests and they requested the school management to lessen their burden by automating this task. The 12th class students are learning C programming and they took up the task of automating the dictation evaluation. Can you please help them out? 
Write a C program to compare 2 strings using strcmp function.

Sample Input:
Enter the word
Excellent
Enter the word the student has typed
Excellent
Sample Output:
It is correct

Sample Input:
Enter the word
Excellent
Enter the word the student has typed
Excelent
Sample Output:
It is wrong

Program Code:
#include<stdio.h>
#include<string.h>
int main()
{
    char str1[100];char str2[100];
    int i=0; 
    printf("Enter the word");
    scanf("%s",str1);
    printf("\nEnter the word the student has typed");
    scanf("%s",str2);
    i=strcmp(str1,str2);    
    if(i==0)
    printf("\nIt is correct");
    else
    printf("\nIt is wrong");
    //printf("\nThe number of letters in the name is %d",l);
    return 0;
}

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

1 comments: