By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

Pallendrom string

P: 1
program in c for to check whether the string is pallendrom or not using stack.h file and stack
Sep 9 '10 #1
Share this Question
Share on Google+
4 Replies


Nepomuk
Expert 2.5K+
P: 3,112
Hi!

This sounds like homework... what have you done so far? We won't give you a solution but we'll be happy to help you find one.

Greetings,
Nepomuk
Sep 9 '10 #2

100+
P: 542
If the palindrome was one word (a string of characters) you could make one pointer point to the first letter and a second pointer point to the last letter and compare *p1 with *p2 from within the body of a for loop. If they are == increment p1(++) and decrement p2(--) and continue to compare for equality until the loop condition (< length of the word/2)is reached or the comparison fails. The same principle could be applied to a sentence.
Sep 13 '10 #3

100+
P: 687
This will work, but won't be accepted because it doesn't use (! turbo-c header) stack.h . The solution that may pass is to push the entire string into the stack and then pop it back comparing to it again, so that the first character in the string is compared to the last pushed ( = first popped ) into the stack.
Sep 14 '10 #4

100+
P: 542
@newb16
Yes... I read 'not' in the wrong context.
But in any case I could not have suggested a way of doing it using a stack so I learnt something.
Sep 15 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.