C Programming
Computer Programming

C program to compares two strings and returns an integer number using strcoll() function



Write a program in C The to compares two strings and returns an integer number based on the result of comparison using strcoll() function

\* C program to compares two strings and returns an integer number using strcoll() function *\

# include < stdio.h >
# include < string.h >
int   main( )
{

char str1[100], str2[100] ;
int result ;
printf ("\n Enter the first string : ") ;
scanf("%s", str1 ) ;
printf ("\n Enter the second string : ") ;
scanf("%s", str2 ) ;
result = strcoll( str1, str2 ) ;

if( result > 0 )
{
      printf("\n first string is (alphabetically) greater than second string !") ;
}
else if( result < 0 )
{
      printf("\n first srting is (alphabetically) less than second string !") ;
}
else
{
      printf("\n Both the strings are equal !" ) ;
}
return 0 ;

}

Output of Program :

Output of C program to compares two strings and returns an integer number using strcoll() function