Solved

C Programming

Posted on 2003-03-02
Medium Priority
141 Views
I am quite new to c programming but i was wondering if any one can help me.

i have a unsigned int yearEnrolled = 2001

and i need to be able to detect or assign the last digit of yearEnrolled.  So then i can use a switch statement to produce a ID - eg. if last digit is 0 = A, 1 = B etc.
Does anyone know how i can do this by only getting the last digit.

Thanks
0
Question by:supreme_commander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3

LVL 101

Expert Comment

ID: 8054009
yearEnrolled mod 10

This will return the remainder of the integer yearEnrolled divided by 10.  Which is always the 1's digit

mlmcc
0

LVL 84

Accepted Solution

ozo earned 300 total points
ID: 8054062
unsigned int yearEnrolled = 2001;
unsigned int lastdigit = yearEnrolled % 10;
char ID='A'+lastdigit;
0

LVL 101

Expert Comment

ID: 8054236
You're right.  Keep mixing all my languages.

mlmcc
0

Expert Comment

ID: 9447407
supreme_commander:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

LVL 101

Expert Comment

ID: 9447750
Points - ozo

mlmcc
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Make the most of your online learning experience.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project
Suggested Courses
Course of the Month10 days, 11 hours left to enroll