#include <iostream.h>
#include <conio.h>
#include<stdio.h>
int compare (int i,char str1[],char str2[]);
void main ( )
{
int i , j , count = 0 ;
char str1[40],str2[40] ;
for (i=0 ; i<40 ; i++)
{
str1[i] = '\0' ;
str2[i] = '\0' ;
}
puts ("Enter the first string :") ;
gets (str1);
puts ("\nEnter the second string :") ;
gets (str2);
count = compare (i,str1,str2);
if ( (str1[count] == '\0')&&(str2[count]=='\0'))
puts ("\nThe two strings are equal.") ;
else
puts ("\nThe two strings are unequal.") ;
getch ( ) ;
}
int compare (int i,char str1[],char str2[])
{
i = 0 ;
while ((str1[i]==str2[i])&&(str1[i]!='\0')&&(str2!='\0'))
++i ;
return (i) ;
}
0 comments:
Post a Comment