Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

C Programming

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
supreme_commander
Asked:
supreme_commander
  • 3
1 Solution
 
mlmccCommented:
yearEnrolled mod 10

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

mlmcc
0
 
ozoCommented:
unsigned int yearEnrolled = 2001;
unsigned int lastdigit = yearEnrolled % 10;
char ID='A'+lastdigit;
0
 
mlmccCommented:
You're right.  Keep mixing all my languages.

mlmcc
0
 
CleanupPingCommented:
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
 
mlmccCommented:
Points - ozo

mlmcc
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now