0% found this document useful (0 votes)
12 views1 page

Vishal

This C program compares two strings entered by the user and checks if they are equal. It takes the strings as input, gets their lengths, then uses a for loop to compare characters and sets a flag if they are equal. The flag is then checked after the loop to determine if the strings are equal or not.

Uploaded by

Sahi Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Vishal

This C program compares two strings entered by the user and checks if they are equal. It takes the strings as input, gets their lengths, then uses a for loop to compare characters and sets a flag if they are equal. The flag is then checked after the loop to determine if the strings are equal or not.

Uploaded by

Sahi Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

// Online C compiler to run C program online

#include <stdio.h>
#include<string.h>
int main() {
char a[100],b[100];
int l1,l2,flag;
printf("enter the string a\n");
gets(a);
printf("enter the string b\n");
gets(b);
l1=strlen(a);
l2=strlen(b);

for(int i=0;i<l1;i++)
{
if(l1!=l2)
{
printf("str1 not equal to str2\n");
break;
}
else if(l1==l2)
{
if(a[i]==b[i])
{
flag=1;
}
else{
flag=0;
break;
}
}
}
if(flag==1)
{
printf("str1 is equal to str2\n");
}
else if(flag==0)
{
printf("str1 not equal to str2\n");
}
return 0;

You might also like