Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm attempting to teach myself C

Status
Not open for further replies.

RWild

Programmer
Nov 14, 2003
53
0
0
US
Ok, I've decided to pick up on C. So I enrolled in this class, and the teacher, well umm...doesn't seem to teach it so well.

So I decided to go ahead and attempt to gain a better understanding of C and teach myself. In the process I plan on going through and doing all the programs in the book.

I was doing pretty well, then I came across this problem. I'm only in Chapter 3 of the book, so this may seem like a basic program to C Vets, but I am a newbie to the C Language, and I don't know what to do.

Here is the problem:

"Create a program that allows the user to enter a 5 digit number, then identify if that number is a palindrome or not.
(HINT: Use division and remainder's)"

...Now I'm just lost, I've looked in the book to see what I could do but no help.

So I have a simple request.
Would somebody be kind enough to type up this program and use //comments to describe some of the steps. It would really be great, and you could just post it in here.

IF that is asking too much, would anybody be able to give me a push in the right direction.

Thanks in advance for any help offered!
 
So is this an algorithm question or a C question?

The algorithm doesn't care about the language, you would use pretty much the same approach in a wide variety of languages.

What the hint is saying is that
abcde % 10 gives you e
abcde / 10 gives you abcd

Do that 4 more times, then compare a==e and b==d

--
 
Don't forget c == c :-D

Just to perhaps clarify, the abcde above is a 5-digit integer; each letter represents a digit.
 
Ok! Thanks guys! I will try this out. If I run into anymore problems, I will be sure to post it up here. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top