Check If A String Is A Palindrome | C++ Example

  Рет қаралды 32,249

Portfolio Courses

Portfolio Courses

Күн бұрын

An example of how to check whether a string is a palindrome or not using C+.+ Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!

Пікірлер: 35
@rupertzoone3512
@rupertzoone3512 Жыл бұрын
Clear and smooth explanation with good example.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thank you for the kind feedback Rupert. :-)
@88NA
@88NA Жыл бұрын
this example is very well explained. thank you.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome, I'm glad you enjoyed it! :-)
@abugslife2461
@abugslife2461 Жыл бұрын
Very helpful! Thank you so much!
@carsmiles4035
@carsmiles4035 9 ай бұрын
Thank you so much for going into details! It is extremely helpful!
@rakshithgowdahc9250
@rakshithgowdahc9250 Жыл бұрын
here in if statement can u explain the indexing how we did it?? because if text length is 10-1-1==8,how we are comparing is it the correct way what I calculated
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Great question Rakshith! Remember that i starts off at 0. So if the length is 10 then we get 10 - 1 - i which is 10 - 1 - 0 which is then 9. And that would mean we are comparing the element at index 0 with the element at index 9, which is exactly what we want because (due to zero-indexing) the last char in the string will be at index 9. :-)
@asthagothi7151
@asthagothi7151 8 ай бұрын
The only explanation i needed
@christosvrettos8257
@christosvrettos8257 Жыл бұрын
Great explanatory video!!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thank you very much Christos, I'm glad you enjoyed it! :-)
@Vichained
@Vichained 2 жыл бұрын
Hey Kevin, could you do this exact examply but using stack allocation and vectors?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
I'm not sure, maybe one day! 🙂
@merveilleuxguiradoumadji290
@merveilleuxguiradoumadji290 2 жыл бұрын
thank you so much,that was very hard for me .
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Merveilleux! 😀
@waed5893
@waed5893 Жыл бұрын
Thank you for video 👏 But if you can make video to check if we can make number palindrome after swaping their digits.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thank you for the video idea Waed, I will add that idea to my list of video ideas. :-)
@alexandrstrekalovskiy4083
@alexandrstrekalovskiy4083 Жыл бұрын
Many thanks for video!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Alexandr! :-)
@fovv3783
@fovv3783 Жыл бұрын
couldn't you add another empty string, then with for loop from back add reversed text to this empty string and then check if they are equal? I mean it is working in c# and i am not sure if you can do this in c++.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Yes, it sounds like that approach would work too! :-)
@alshaimaahassan3512
@alshaimaahassan3512 Жыл бұрын
Many thanks for video
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Alshaimaa! :-)
@abdelhakmezenner2855
@abdelhakmezenner2855 2 жыл бұрын
damn that was in my last exam of c programming 😂 it was so hard for me .. but now its a little bit easier
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
I’m glad to hear this made it a bit easier Abdelhak! :-)
@HowDoYouTurnThisOn_
@HowDoYouTurnThisOn_ 6 ай бұрын
which line of code checks if the two characters are the same?
@ryanthelove
@ryanthelove 6 ай бұрын
if (palindrome[i] != palindrome[palindrome.length() - i - 1])
@urishitapandita8447
@urishitapandita8447 2 жыл бұрын
why did the text.length got divided by 2?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Great question Urishita! 🙂 We want to compare the 1st element to the last element, the 2nd element to the 2nd last element and so on to see if all of the corresponding elements match. So we really only need our loop counter variable to go until the middle of the string. Once we reach the middle of the string, we will have compared the 1st element to the last, the 2nd element to the 2nd last element, and so on. We could go keep past the middle of the string, but we would just end up making the same comparisons again, so for example by the last run of the loop we would just e comparing the last element to the 1st element again. We save work by only checking up until the middle of the string as that is all that is required. 🙂
@urishitapandita8447
@urishitapandita8447 2 жыл бұрын
@@PortfolioCourses okayy thank youu so much for your reply
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome! :-)
@gokulakrishnan9141
@gokulakrishnan9141 Жыл бұрын
Love you sooo much man❤
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Haha thanks, love you right back ❤️
@yodakash6284
@yodakash6284 9 ай бұрын
fake!!!!!!
@PortfolioCourses
@PortfolioCourses 9 ай бұрын
What? :-)
Singleton Design Pattern | C++ Example
13:24
Portfolio Courses
Рет қаралды 15 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Je peux le faire
00:13
Daniil le Russe
Рет қаралды 20 МЛН
how Google writes gorgeous C++
7:40
Low Level Learning
Рет қаралды 879 М.
Check If A String Is A Palindrome | C Programming Example
10:56
Portfolio Courses
Рет қаралды 37 М.
How computer processors run conditions and loops
17:03
Core Dumped
Рет қаралды 88 М.
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 941 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 781 М.
Dear Functional Bros
16:50
CodeAesthetic
Рет қаралды 505 М.
why are switch statements so HECKIN fast?
11:03
Low Level Learning
Рет қаралды 408 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,7 МЛН
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 306 М.