Program to compare two strings are equal or not.
Code :
#include <stdio.h>
#include <stdlib.h>
void stringcompare(char arr[100], char arr2[100]);
int main()
{
char arr[100], arr2[100];
stringcompare(arr,arr2);
}
void stringcompare(char arr[100], char arr2[100])
{
int ans,length,result;
printf("\nEnter string : ");
gets(arr);
printf("\nEnter 2nd String: ");
gets(arr2);
int i,counter=0,j,lenght,lenght2;
for(i=0;arr[i]!='\0';i++)
{
}
lenght=i;
for(j=0;arr[j]!='\0';j++)
{
if(arr[j]==arr2[j])
{
counter++;
}
}
if(counter==lenght)
{
printf("\n\tEqual");
}
else{
printf("\n\tNot Equal\n");
}
}
Code :
#include <stdio.h>
#include <stdlib.h>
void stringcompare(char arr[100], char arr2[100]);
int main()
{
char arr[100], arr2[100];
stringcompare(arr,arr2);
}
void stringcompare(char arr[100], char arr2[100])
{
int ans,length,result;
printf("\nEnter string : ");
gets(arr);
printf("\nEnter 2nd String: ");
gets(arr2);
int i,counter=0,j,lenght,lenght2;
for(i=0;arr[i]!='\0';i++)
{
}
lenght=i;
for(j=0;arr[j]!='\0';j++)
{
if(arr[j]==arr2[j])
{
counter++;
}
}
if(counter==lenght)
{
printf("\n\tEqual");
}
else{
printf("\n\tNot Equal\n");
}
}
Post a Comment