Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I am trying to program the following:

declare a char array of size 16, populate it with random chars (small characters)
write a function bool is_palindrome which checks if the characters constitute a palindrome
it should output is or is not a palindrome
I am preparing for something and do not know how to go about this, please help?

What I have tried:

I would like to know how to return the false, if you may show me a sample code that'd help
Posted
Updated 12-Oct-17 10:03am
Comments
F-ES Sitecore 12-Oct-17 11:15am    
We're not here to do your homework for you. If you can't find the solution to one of the most frequently asked homework questions then academic pursuits might not be for you.
PeejayAdams 12-Oct-17 11:25am    
Hint: You've accidentally written most of the code required to return false in your "What I haven't been arsed to try" section - take three of the words, drop one of them, add a semi-colon and think about your life choices.
Rick York 12-Oct-17 11:42am    
When I have a "tricky" algorithm to figure out I first think about how I would do it mentally or mechanically, meaning not in code. Then I translate those steps into code, preferably with functions named nearly the same as the conceptual steps.

Quote:
I would like to know how to return the false, if you may show me a sample code that'd help
Try:
C++
return true;
Or
C++
return false;
 
Share this answer
 
Comments
Member 13426989 25-Oct-17 15:16pm    
thank you for guiding me.
Take a sheet of paper and a pencil. And solve some samples.
You solved the problem by following a procedure, that procedure is your algorithm. You need to write down the steps in a mechanical manner (computer like). The program will follow those steps.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900