integer format question

This is a discussion on integer format question within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, I am working on a date class program that manipulates dates and times and outputs them in different ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    5

    integer format question

    Hello everyone,

    I am working on a date class program that manipulates dates and times and outputs them in different formats and such.

    I have a simple question:

    Say I have a date, which is an integer, and is inputed like this:
    1999 or 2004

    4-digits, always. How do I output the LAST TWO digits without changing the value of the date itself???

    example:
    1999 ---> 99
    2004 ----> 04

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    %100

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    5
    can you give me a code example??

  4. #4
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    Code:
    cout << (1999 % 100);

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access Violation
    By Graham Aker in forum C Programming
    Replies: 100
    Last Post: 01-26-2009, 07:31 PM
  2. Seeking Format Advice
    By PsychoBrat in forum Game Programming
    Replies: 3
    Last Post: 10-05-2005, 05:41 AM
  3. How to display integer to binary format?
    By franziss in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2005, 11:32 PM
  4. Help with homework please
    By vleonte in forum C Programming
    Replies: 20
    Last Post: 10-13-2003, 11:16 AM
  5. Linked Lists Integer addition ? HELP Please??
    By green_eel in forum C Programming
    Replies: 3
    Last Post: 03-12-2003, 03:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21