How would I single out the last digit of a four digit code?

I have been tasked with determining the origin of an orange. If the last digit is 7 then the orange is from Florida. If the last digit is 4 the digit is from California. If the last digit is neither 4 nor 7 I would have to label it as "invalid code".

How would I single out the last digit of a four digit number? It was an easy concept to grasp at first by just determining the positives and negatives. Now it is a little more specific and I have not seen an example in the lesson to throw me a bone as to what I should be doing.

Any ideas?

This is what I have so far.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
    		// Declare variables
		int orangesCode = 0;
    	int remainder = 0;
    	double LastDigit = 0.0;

		// Request input
		cout << "Enter the orange's 4-digit code: ";
		cin >> orangesCode;
	
		// Determine location
		remainder = orangesCode % 2;
		
		
    	if (remainder == 0)
    		{
    			
    	
    			cout << "Origin: California" << endl;   
			    
    		}
		if (remainder == 1)
    		{
    			cout << "Origin: Florida" << endl;   
			}
			
		else if 
	   		{
				
				cout << "Invalid code" << endl;
				
			}
     
    		system("pause"); 
    		return 0;
}


Thanks!
remainder = orangesCode % 2;

You obviously know about the modulo operator. What happens if instead of a 2, you use a 10 there?
Wow... I have no idea why I overlooked that, something so simple. Time for some coffee, I appreciate it!
Topic archived. No new replies allowed.