external_5.c
Source Code
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int isPalindrome(char []);
int main() {
char str[50];
printf("Enter the string (upto 50 char): ");
fgets(str, sizeof(str), stdin);
if(str[strlen(str) - 1] == '\n') str[strlen(str) - 1] = '\0';
if(isPalindrome(str)) printf("\n\"%s\" is palindrome.", str);
else printf("\n\"%s\" is not palindrome.", str);
return 0;
}
int isPalindrome(char str[]) {
int len = strlen(str);
int start = 0, end = len - 1;
while(start < end) {
if(tolower(*(str + start)) != tolower(*(str + end))) return 0;
start++;
end--;
}
return 1;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26