Check If A String Is A Palindrome | C Programming Example

  Рет қаралды 44,877

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 41
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Check out this video too on using recursion to check if a string is a palindrome! 🙂 kzbin.info/www/bejne/sILFiWmobbKUna8.
@victor.san3
@victor.san3 2 жыл бұрын
Your code is really elegant and straightforward it makes so much easier to understand. Also, great pedagogical skills there. Thanks a lot!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you so much for the positive feedback Victor, and you're very welcome! 😀
@pratikthapa6218
@pratikthapa6218 2 жыл бұрын
this was the way i actually wanted to do it thanks mate upload more of this you are a clever man
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Pratik! :-) If you liked this video then you might you like some of the other videos in this playlist: kzbin.info/www/bejne/qZbTfGitabqYppI
@srujanreddy8023
@srujanreddy8023 Ай бұрын
hey kevin, firstup a big thanks for eveything. i just thought can we make use of strrev and strcmp and conclude if the given string is palindrome or not......
@pogCibi
@pogCibi Жыл бұрын
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?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
The length returned by strlen() does not count the null terminator, so that’s why it works out correctly length-wise.
@pogCibi
@pogCibi Жыл бұрын
@@PortfolioCourses Thank you!
@EuaggelosSP
@EuaggelosSP 2 жыл бұрын
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.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Great question! :-) One thing you could do is include the ctype libray at the top of the file with #include and then change this line to: if (tolower(string[i]) != tolower(string[len - i - 1])) return false; The tolower() function will convert both letters to lowercase letters (if they are uppercase letters, otherwise it just returns the original character). The function is covered in this video if you want to learn more: kzbin.info/www/bejne/l4W2e3mlprmNqKs.
@LuSanFR
@LuSanFR Жыл бұрын
I got stuck on this in my 42 piscine final exam !
@barnikroy5244
@barnikroy5244 2 жыл бұрын
Thank you for this playlist
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Barnik! :-D
@justcurious1940
@justcurious1940 Жыл бұрын
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; }
@comoyun
@comoyun 8 ай бұрын
looks similar to mine: int isPalindrome(char word[]) { int status = 1, i = -1, length = 0; while (word[++length] != '\0'); while (i++ < length / 2) { if (word[i] != word[length - i - 1]) { status = 0; break; } } return status; }
@charlescox290
@charlescox290 11 ай бұрын
I'm surprised you didn't calculate len and then calculated middle using len and save a function call.
@michaelsotheraccount9070
@michaelsotheraccount9070 4 ай бұрын
How come the if statement within the int main doesn't have {} am I cooked?
@omarmohamed-zo3dp
@omarmohamed-zo3dp 7 ай бұрын
what would be the right code if i want the user to input any word to check
@umarahmed3113
@umarahmed3113 2 жыл бұрын
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
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Did you try the code in this video? 🙂 It is available here and it should work: github.com/portfoliocourses/c-example-code/blob/main/palindrome.c
@umarahmed3113
@umarahmed3113 2 жыл бұрын
@@PortfolioCourses im not sure if ittl work because im doing the leetcode on a site called codesignal. If you're able to do the coding for that task on there, can you make a tutorial?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@umarahmed3113 If it's C they're using, it should work on there too. 🙂 I'm not sure if I can do a tutorial on that, maybe one day I can cover some leetcode questions as it does seem to be popular with learners. 🙂
@KarouiFulla-m6e
@KarouiFulla-m6e Жыл бұрын
Thank you so much
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re very welcome! :-)
@glennpableo7030
@glennpableo7030 2 жыл бұрын
it did not work for me
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Can you post your code in a comment here so we can check it out? The original code is found here, it should work: github.com/portfoliocourses/c-example-code/blob/main/palindrome.c
@yunusemrebayraktar5147
@yunusemrebayraktar5147 Жыл бұрын
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
@PortfolioCourses
@PortfolioCourses Жыл бұрын
It looks good to me Yunus, thanks for sharing! :-)
@yunusemrebayraktar5147
@yunusemrebayraktar5147 Жыл бұрын
@@PortfolioCourses Thanks 😃
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@yunusemrebayraktar5147 🙂
@tanker1425
@tanker1425 Жыл бұрын
nice
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thanks!
@sketchupguru
@sketchupguru 2 жыл бұрын
Malayalam is a great palindrome word
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
That’s a pretty long one, I’ll remember that thanks! :-)
@sketchupguru
@sketchupguru 2 жыл бұрын
@@PortfolioCourses haha sure. YOu should look it up. It's a south Indian Language that I speak.
@phanindraslvs7469
@phanindraslvs7469 Жыл бұрын
👍🏼👍🏼
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thanks Phanindra! :-)
@ArjunA-ln3ov
@ArjunA-ln3ov 9 ай бұрын
/0
@tanker1425
@tanker1425 Жыл бұрын
nice
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thanks!
Check If A String Is A Palindrome | C++ Example
11:18
Portfolio Courses
Рет қаралды 37 М.
you will never ask about pointers again after watching this video
8:03
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Check If A String Is A Palindrome Using Recursion | C Programming Example
9:36
Sum the Values in an Array | C Programming Example
7:17
Portfolio Courses
Рет қаралды 29 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 344 М.
Learning C# In A Week... Otherwise I Fail University
9:04
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 639 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,3 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Special Programs in C − Check If The Number Is Palindrome Number
8:14
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН