Tuesday, December 30, 2014

Program Compares Two Strings to Check Whether They are equal or not



Program Compares Two Strings to Check Whether They are equal or not

#include <stdio.h>

#include <string.h>

int main( )

   {

    char a[20] ,  b[20];

    printf("n Enter the first string:");

    scanf("%s",a);

    printf("n Enter the second string:");

    scanf("%s",b);

    if((strcmp(a,b)==0))

      {

printf("nStrings are the same");
}
else
{
printf("nStrings are different");
}
return 0;
}

No comments:

Post a Comment