Computer Scientists are Pretty Pessimistic

Saturday 5 September 2015

WAP to compare two strings

#include <stdio.h>
#include <string.h>
int main ()
{
    int i,j,m=0;
    char a[100],b[100];
    printf("Enter a string: ");
    gets(a);
    printf("Enter another string: ");
    gets(b);
    for(i=0;i<a[i];i++)
    {
        if(a[i]==b[i])
            m++;
    }
    if(m==strlen(a))
        printf("\nMatched\n");
    else
        printf("\nNot Matched\n");

    return 0;
}

2 comments: