how to create a date and month format using three numbers

dear professors I'm new comer for the c++ language. So i like to study it like a professional person so i need a help can anyone tell how to format this 148 number to the date and month format. I tried to find the answer of this question searching lot of ways but i failed it please help me that question i hope someone give a good answer thank you!
Last edited on
When you type like this no one can understand you try to use punctuation also not everyone here is a professor just letting you know for future reference

As for your problem, you probably don't want to store a three digit number to represent the time and date.
@IWishIKnew sir i don't want format it as time and date
i need to format this three digits to month and date. please think like this.
148 is starting date of january first and ending then it the birth date like. did u got the mean?? bcz ma english is not well
Your problem might be:
Convert a number (1-365) to a date? Some conversions would be:
1: January 1
2: January 2
32: February 1
365: December 31
assume it is not a leap year.

ie Julian day to date conversion. Typical course problem; not too easy, not too hard. Needs arrays and 0 or 1-based counting. Solve for month and day.
Last edited on
@ShodanHo can you show me an example
Start with an array of days in each month:
int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
(1) First work out which month you are in.
(2) then work out which day you are in.
As an example:
if you are converting day 100, then to end of each month will be:

jan: 31 < 100
feb: 31+28 < 100
mar: 31+28+31 < 100
apr: 31+28+31+30 >= 100

(1) so day 100 must be in April
(2) the remaining days from March onwards must constitute the day.

Check for 0 or 1-based numbering problems in the month and the day! Our array of months will make January to be month 0. etc

If you're going to pass the course, the rest should be easy.
Last edited on
ok, well, you'll only be able to store the months between january and september...

12 = max months...
I assume you're using a 2-digit year value (which is erroneous, by the way: remember "y2k"?).

You're gonna have to do a bit more to store dates than just 3-digit numbers.

hmm... you could try hex values though... (for the month, anyway...)
************************************************************
ah, I read shodan's post and now I know what you mean. You want to know the Nth day of the year as a date.

Simple:

calculate the date from january 1st, knowing the year, and the number of days in each month.
Last edited on
hey friends anybody know how to create a date object for this question.????
i think it's the best way for this question
Topic archived. No new replies allowed.