### How do I do this?

I have an assignment for my programming class that requires me to " use switch in this exercise)
Write a C++ program that asks for a number between 15 and 256. Use the digit of ones of the generated number to display one of the following messages :

“Valencia Community college” if the digit of ones is divisible by 5, equal to 3 or 4
“UCF” is the digit of ones is greater than 5
“Colonial High” is the digit of ones is either 1 or 2
"

the problem is that i have no idea how to isolate the ones place of an integer and use it for a switch statement. Any help on doing this will be much appreciated.
http://www.cplusplus.com/forum/articles/1295/

You might want to look into arrays
try to define your problem in the title, don't put things like "help me" or "how do I do this", you'll get more responses

to find the ones place of an integer all you have to do is determine the remainder of the number divided by 10.

last_digit = number%10;

for this to work number has to be an int, not a floating point number

for example if you use the number 15, 15%10 gives you the remainder of 15/10, or 5.
using 256, 256%10 gives you the remainder of 256/10, or 6.
Last edited on
Topic archived. No new replies allowed.