c program to compare whether two given strings are equal or not. Print True if two strings are equal. Otherwise print False.
Program:
#include<stdio.h>
#include<string.h>
int main()
{
char string1[50];
char string2[50];
int a;
printf("enter string1: ");
scanf("%s",string1);
printf("enter string2: ");
scanf("%s",string2);
a=strcmp(string1,string2); /* strcmp() returns 0 if two strings are equal,
returns 1 if not equal */
if(a==0)
printf("\nTrue");
else printf("\nFalse");
return 0;
}
Sample input and output:
enter string1: india
enter string2: india
True
enter string1: india
enter string2: pakistan
False