Check If A String Is A Palindrome | C Programming Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Your code is really elegant and straightforward it makes so much easier to understand. Also, great pedagogical skills there. Thanks a lot!

victor.san
Автор

this was the way i actually wanted to do it thanks mate upload more of this you are a clever man

pratikthapa
Автор

Just a string a weird syndrome :

_Bool is_Syndrome(char *string){
int length = strlen(string);
int middle = length/2;
for(int i = 0 ; i < middle ; i++){
if(string[i] != string[length-1-i])
return false;
}
return true;
}

justcurious
Автор

what would be the right code if i want the user to input any word to check

omarmohamed-zodp
Автор

What do I do if I want my program to ignore cases, for example if I input Wow it says its not a palindrome because of the capital W.

EuaggelosSP
Автор

I'm surprised you didn't calculate len and then calculated middle using len and save a function call.

charlescox
Автор

I have a question, doesn't the strings also have a terminating null character 0? So why is it not a problem when we are taking it's lenght?

pogCibi
Автор

So I got the right code for the palindrome if it’s something like aabaa but I don’t know what to do for something like aabaaa

umarahmed
Автор

int main() {

int i, length, check;
char string[20];
char reverse_string[20];

printf("Enter a string: ");
scanf("%s", string);
length = strlen(string);
for(i=0;i<length;i++) {
reverse_string[length-1-i] = string[i];
}
for(i=0;i<length;i++) {
check=1;
else {
check=0;
break;
}
}
if(check == 1) printf("This is a palindrom!");
else printf("This is NOT a palindrom");
return 0;
}

I guess i chose the long way.😅

yunusemrebayraktar
Автор

I got stuck on this in my 42 piscine final exam !

DLikeDick