Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m trying to make program by using putty... but I\'m having trouble making it.

ID: 3630662 • Letter: I

Question

I'm trying to make program by using putty... but I'm having trouble making it..

If I finish make the program and type a.out filename.., I should see "Enter the year: " and "Enter the day number: "

So, I put the year as 2011 and day number as 15

and, the following resuly should be like the below

Day #: 15

January 15, 2011

for another example, I put year as 2008 and day number as 60, I should get

Day #: 60

February 29, 2008

for the last example, I put year as 2011 and day number as 60, I should get

Day #: 60

March 1, 2011

I think I need to use Leap function (Leap Year) in order to make the program result like the above...

Please make the proper program based on putty system so that I can get those result.

Explanation / Answer

Source code for this program is below, written in C/C++. PuTTY isn't a programming language, but a remote access method for connecting to another computer. If you're connecting to a Linux or UNIX system, which is likely, create a new text file with the contents of the code below. Call it "dates.c" and save it in a directory. From that same directory, run "gcc dates.c" from the command prompt. Now you should be able to type "./a.out" and execute the program. #include int monthLengths[] = { 31, // January 28, // February 31, // March 30, // April 31, // May 30, // June 31, // July 31, // August 30, // September 31, // October 30, // November 31 // December }; char* monthNames[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; /* Returns 1 if the year is a leap year and 0 otherwise */ int isLeapYear(int year) { if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) { return 1; } else { return 0; } } else { return 1; } } else { return 0; } } int main() { int year; int dayNumber; printf("Enter the year: "); scanf("%d", &year); printf("Enter the day number: "); scanf("%d", &dayNumber); printf("Day #: %d ", dayNumber); if (isLeapYear(year)) { monthLengths[1]++; } int i = -1; int daysUsed = 0; int dayWithinMonth = dayNumber; while (daysUsed