From: Ryan on
I am inputing a year value and I want to create two variables, one
only taking the first two digits of the year and the second taking the
last two digits of the year.

So, for example, if I input year = 1999, I want to assign the first
variable the value 19 and the second variable 99.

How do I do this?

Thanks

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Oncaphillis on
Ryan wrote:

> I am inputing a year value and I want to create two variables, one
> only taking the first two digits of the year and the second taking the
> last two digits of the year.
>
> So, for example, if I input year = 1999, I want to assign the first
> variable the value 19 and the second variable 99.
>

int year = 1999; // e.g
int a = year / 100; // will be 19
int b = year % 100; // will be 99

O.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Daniel T. on
Ryan <rwesslen(a)gmail.com> wrote:

> I am inputing a year value and I want to create two variables, one
> only taking the first two digits of the year and the second taking the
> last two digits of the year.
>
> So, for example, if I input year = 1999, I want to assign the first
> variable the value 19 and the second variable 99.
>
> How do I do this?

What have you been taught about the language so far? Have you made any
attempt at all of solving it yourself? If so, post what you have and you
will get help.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]