A palindrome is a word or sentence that reads the same forward as it does backward. Write C++ code that read string consist of 6 characters only and check if the string palindrome word or NOT.

Recommended Answers

All 21 Replies

We don't do your homework for you.

What are you struggling with? How far have you got? Do you understand how to actually do this? By which I mean, can you tell me which of these two words is a palindrome: CATFISH CIVIC

@assembly boy .. what's wrong with .. if u don't wanna answer .. then don't -,-'

If you actually read the rules before you posted this, you would see how inappropriate the post is. This site basically helps those that helps themselves. Show some effort with a specific problem and people will be more than happy to help. But we won't do your homework for you.

by the way, when you implore people to answer you, even saying that they won't help you is an answer.

. if u don't wanna answer .. then don't -,-'

Same to you. I asked you questions, you didn't answer.

What ?
I didn't see any question .. sorry .. but I registered yesterday

Uhh
Actually I didn't understand

what part(s) of the assignment don't you understand? Post your attempt to at least begin the assignment.

Guys .. u thought that I never tried .. I tried alot..but I wanna a Convincing answer ..

I wanna a Convincing answer ..

You must first show an effort towards solving the problem. What code do you have so far? What problems does your code so far have?

Guys .. u thought that I never tried .. I tried alot.

Prove it. Not only does it show us that you're not just looking for a handout, but it also helps us to determine your level for tailoring help to you. Further, instead of a lot of back and forth, you might find that your problems are actually easy to fix when someone more experienced has a look at the code you have.

Member Avatar for iamthwee

Break the program down.

1) Define the entry point.

#include <iostream>
#include <string> //for strings

using namespace std;

int main()
{


 return 0;

}

2) Create a message for user input

cout << " Please enter a string only 6 characters long:" << endl;

3) Create a variable to store the string

string word;

4) store the string using cin

cin >> word;

5) Make sure it has only 6 characters
6) Do the clever stuff to check if it is a palindrome.

Come back here to ask further questions.

And how did u checked the word .. if its palindrome or not ?

And how did u checked the word .. if its palindrome or not ?

He's leaving that up to you. It's simple if you break it down into small steps. A palindrome is where a word is the same forwards as it is backwards. For example the word redder is 6 letters long and it is a palindrome. We can check this systematically by looking at the first and last letters. Are they the same? Yes. Continue. Look at the 2nd and 2nd to last letters. Are they the same? Yes. We'll check the last pair of letters, the 3rd and the 3rd to last. They are the same too. This renders the word a palindrome.

You could do this another way by simply creating a char[6] buffer and load it with the word the user entered, but backwards. For example, if the user entered Pooled, then your new buffer would end up containing delooP. Then you can simply call strcmp on the original and the reversed. If they are the same, then the word is a palindrome - because, well, palindromes are the same forwards as backwards.

i think i didn't take the lesson coz the teacher gave the idea today about the palindrome.. and the teacher herself couldn't explain it .. uhh GOD! :'(
WTH .. how can I solve it without any idea about it even .. and the submission is today.

Assembly Guy told you how to solve it -- nobody is going to write the program for you. I'm sure if you just used google you could find lots of programs.

I google it ..
U know what .. don't fucknn solve it

Looks like now we come to the root of the problem. You don't know how to use Google.

When I use "palindrome c++ source code" as the search term, in the first page I get these examples:

Click Here
Click Here
Click Here
Click Here
Click Here

The complexity differs from very basic to higher end, but it shouldn't be too hard to find code that works.

Member Avatar for iamthwee

If you make enough noise somebody is surely going to post up an entire answer?

Or you could have just done your homework. Lesson learned hey?

I'm sure that when you get a job as a programmer your boss will be really glad that you know how to use Google, but I don't know how happy he's going to be that you can't write a program to save your life...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.