Category : C Source Code
Archive   : QCTBOX.ZIP
Filename : CALTEST.C

 
Output of file : CALTEST.C contained in archive : QCTBOX.ZIP
/*---------------------------------------------------------------------
Name: Caltest.c
Type: Demonstration Program
Language: Mic. QC
Video: (no special video requirements)

Program list: CALTEST.C
CALENDAR.C

Variables: m1 Month num. for first date
d1 Day num. for first date
y1 Year num for first date
m2 Month num. for second date
d2 Day num. for second date
y2 Year num for second date
m3 Month num. for third date
d3 Day num. for third date
y3 Year num for third date
j1 Julian day number for first date
j2 Julian day number for second date
j3 Julian day number for third date
i Looping index for each day of month
n Number of days in month
wd Day of the week number
month1 Calendar page for first month
month2 Calendar page for second month
month3 Calendar page for third month

Usage: (no command line parameters)

Description: Demonstrates the calendar toolbox functions
-------------------------------------------------------------------------*/

#include
#include
#include
#include"calendar.h"

main()
{
char date[11];
int m1, d1, y1;
int m2, d2, y2;
int m3, d3, y3;
long j1, j2, j3;
int i, wd;
char month1[MON_ROW][MON_COL];
char month2[MON_ROW][MON_COL];
char month3[MON_ROW][MON_COL];

/*Ask user for date of birth */
printf("\n\nEnter the date of your birth\n\n");
printf("Month (1 to 12)..?");
scanf("%2d", &m1);
printf("Day (1 to 31)..?");
scanf("%2d", &d1);
printf("Year(example 1952)..?");
scanf("%4d", &y1);

/* Convert the date to a formatted string */
datestr(m1, d1, y1, date );
printf("\nYour birthday:\t\t%s\n", date);

/* Verify that date matches reality */
if(!validate(m1, d1, y1))
{
printf("Invalid date!(RUN the program again)\n");
exit(0);
}

/*Find astronomical Julian day number for birthdate*/
j1 = date_to_julian( m1, d1, y1);
printf("Julian day number:\t%ld\n", j1 );

/*Find day of week */
wd = day_of_week(m1, d1, y1 );

/* Display information about birth date */
printf("Weekday name: \t%s\n", weekday_name( wd ));
printf("Month name: \t%s\n", month_name( m1 ));
printf("Day of year: \t%d\n", day_of_year(m1, d1, y1));
printf("Day of century: \t%ld\n", day_of_century(m1, d1, y1));

/* Find Julian day number for 10,000 days after birth date */
j2 = j1 + 10000;
/* Convert to date */
julian_to_date( j2, &m2, &d2, &y2 );

/* Make a formatted string from the date numbers */
datestr( m2, d2, y2, date );

/* Display new date */
printf("Plus 10,000 days\t%s\n", date);

/* Wait for user */
printf("\n\nPress any key to continue...");
getch();
/*Get todays date from system clock */
date_get( &m2, &d2, &y2 );

/* Find the Julian day for today */
j2 = date_to_julian(m2, d2, y2);

/* Calculate the Julian day number for half your life ago */
j3 = ( j1+j2 ) / 2;

/* Find the half-lifetime date for user */
julian_to_date( j3, &m3, &d3, &y3 );

/* Create calendar page for month of birth */
one_month(m1, y1, month1 );

/* Create calendar page for present month */
one_month(m2, y2, month2);

/* Create calendar page for month equidistant from other two */
one_month(m3, y3, month3);

/* Display 3 one month calendars */
printf("\n\n\nThe month you were born,");
printf("the current month, and half your life ago...\n\n");
for(i=0; i < MON_ROW; i++ )
printf("%s\t%s\t%s\n", month1[i], month2[i], month3[i] );

/* Display todays date */
datestr( m2, d2, y2, date );
printf("\nToday's date is\t\t%s\n", date );

/* Give user the ugly news */
printf( "Your age in days:\t%ld\n\n\n",
days_between_dates( m1, d1, y1, m2, d2, y2));
}















  3 Responses to “Category : C Source Code
Archive   : QCTBOX.ZIP
Filename : CALTEST.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/