Compare two String function in C Program

//compare string
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char str1[10],str2[10];
printf("input first string:");
scanf("%s",str1);
printf("input second string:");
scanf("%s",str2);
if(strcmp(str1,str2)==0)
{
printf("Both %s and %s are same",str1,str2);

}
else if (strcmp(str1,str2)>0)
{
printf("%s is greater than %s",str1,str2);
}
else
{
printf("%s lesser than %s",str1,str2);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image