48-Write a program to compare two strings.

Program: 48

Write a program to compare two strings.

#include
#include
void main()
{
        char str1[20];
       char str2[20];
        printf("Enter first string: ");
       gets(str1);
       printf("Enter second string: ");
        gets(str2);
        if(strcmp(str1,str2)==0)
            printf("\n Strings are equal");
        else
            printf("\n Strings are not equal");
        getch();
}
Output
Enter first string: EASTER

Enter second string: SCIENCE

Strings are not equal

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.