Ass 4 B 1
Ass 4 B 1
h>
#include<string.h>
#include <stdbool.h>
bool compare(char *str1, char *str2)
{
while (*str1 == *str2)
{
if (*str1 == '\0' && *str2 == '\0')
return true;
str1++;
str2++;
}
return false;
}
void reverse(char* str)
{
int len, i;
char *start, *end, ch;
len = strlen(str);
start= str;
end = str +len-1;
for (i = 0; i < (len-1)/2; i++)
{
ch = *end;
*end = *start;
*start = ch;
start++;
end--;
}
}
int main()
{
char str1[10],str2[10];
printf("enter 2 strings");
scanf("%s",str1);
scanf("%s",str2);
if (compare(str1, str2) == 1)
printf("%s and %s are Equal",str1,str2);
else
printf("%s and %s are not Equal",str1,str2);
//reverse(str1);
reverse(str2);
if(compare(str1,str2)==1)
printf("\nString is pallindrome");
else
printf("\nStrings are not pallindrome") ;
return 0;
}