0% found this document useful (0 votes)
7 views2 pages

Ass 4 B 1

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

Ass 4 B 1

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

#include <stdio.

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;
}

You might also like