Extracting info from a variable

Hi!

Suppose we have this statement.

1
2
3
 int year;
       cout << " Enter the year " << endl;
       cin >> year;


Suppose the user entered 1988 as the year.
Now if I wanted to use the last two digits '88'
how would I extract those numbers from the variable?

For, example; I want to get the variable year and divide the last two digits by a number. How would I do it?

Thanks!
modulus
year % 100; //yields a number between 0-99

1988%100 = 88
12345657811215%100 = 15
Last edited on
Topic archived. No new replies allowed.