?
Solved

C Programming

Posted on 2003-03-02
6
Medium Priority
?
141 Views
Last Modified: 2011-09-20
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
Comment
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
  • Learn & ask questions
  • 3
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
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

by:
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

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

mlmcc
0
 

Expert Comment

by:CleanupPing
ID: 9447407
supreme_commander:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9447750
Points - ozo

mlmcc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question