hello,
i have an assignment to create and print a calendar programme
the prob is, we have to add in various additional features in order to get higher marks
since i'm new to C, i need help and suggestions to improve on my code
also, can anyone please show me how to use the DOWHILE in my code?
thank you very much i really appreciate any help
this is the code we have written:

#include <stdio.h>
#include <stdlib.h>

int DayOfWeek(int year, int month);
int CenturyTable(int century);
int MonthTable(int month, int leapStatus);
int leapYear(int year);
//int numDays(int y);
void printMonth (int startDay, int days);


int main()
{
	int year, month;
	int y;
	int numDays;

	printf("Enter the year for your calender (YYYY): ");
	scanf("%d",&year);
    
	printf("Enter the month for your calender (MM): ");
	scanf("%d",&month);
	

	if(year >= 1800 && year <= 2699)
	{
		y = DayOfWeek(year, month);

		printf("\n\t\t");

		if(y==0)
			printf("1/%d/%d is a Sunday\n",month,year);
		else if(y==1)
			printf("1/%d/%d is a Monday\n",month,year);
		else if(y==2)
			printf("1/%d/%d is a Tuesday\n",month,year);
		else if(y==3)
			printf("1/%d/%d is a Wednesday\n",month,year);
		else if(y==4)
			printf("1/%d/%d is a Thursday\n",month,year);
		else if(y==5)
			printf("1/%d/%d is a Friday\n",month,year);
		else if(y==6)
			printf("1/%d/%d is a Saturday\n",month,year);

		
	}

	else
		printf("Out of Range. Please try again.\n");

	if(month == 2)
	{ 
		if(leapYear(year) == 0)
			numDays = 28;  
		else
			numDays = 29;
	}

	else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
		numDays = 31;
	else
		numDays = 30;

	printMonth(y , numDays);




	system("PAUSE");

	return 0;
}

int DayOfWeek(int year, int month)
{
	int CoEcentury,CoEmonth, leapStatus, sum, a;

	CoEcentury = CenturyTable(year);
	leapStatus = leapYear(year);
	CoEmonth = MonthTable(month, leapStatus);
	
	sum = CoEcentury + CoEmonth + 1;
	
	a = sum%7;

	return a;
}

int CenturyTable(int year)
{
	int century, century1, year1,year2,result;

	century = year/100;//to get the 1st 2 digits of the year eg. 1970=19
	//printf("year/100=%d\n",century);
	
	year1 = year%100;//to get the last 2 digits of the year eg. 1970=70
	//printf("year%100=%d\n",year1);
	year2 = year1 + (year1/4);//year* table formula
	//printf("year + (year/4)=%d\n",year2);

	
	century1 = 2*(3 - (century%4));//century table formmula
	//printf("centurytable=%d\n",century1);
	
	
	result = century1 + year2;//answer of century + year
	//printf("result=%d\n",result);

	return result;
}

int MonthTable(int month,int leapStatus)
{
	int a;
	if((month==1 && leapStatus==0)||month==10)
		a = 0;
	else if(month==3||month==11||(month==2 && leapStatus==0))
		a = 3;
	else if(month==4||month==7||(month==1 && leapStatus==1))
		a = 6;
	else if(month==5)
		a = 1;
	else if(month==6)
		a = 4;
	else if(month==8||(month==2 && leapStatus==1))
		a = 2;
	else if(month==9||month==12)
		a = 5;
	return a;
	/*
	January      0 (in leap year 6)
    February     3 (in leap year 2)
    March        3
    April        6
    May          1
    June         4
    July         6
    August       2
    September    5
    October      0
    November     3
    December     5                      */
}	

int leapYear(int year)
{
	int mod4, mod100, mod400, leap;

	mod4 = year%4;
	mod100 = year%100;
	mod400 = year%400;

	if((mod4==0&&mod100!=0)||(mod400==0))
		leap = 1;//leap year
	else
		leap = 0;//not a leap year

	return leap;
}

void printMonth (int startDay, int days)
{
	int weekDay, dayCount;
	printf("\t\tSun Mon Tue Wed Thu Fri Sat\n");
	printf("\t\t--- --- --- --- --- --- ---\n");
	printf("\t\t");

	for (weekDay = 0; weekDay < startDay; weekDay++)
		printf("    ");

	for (dayCount = 1; dayCount <= days; dayCount++)
	{
		
		if (weekDay > 6)
		   {
			   printf("\n\t\t");
			   weekDay = 1;
		    }
		else
			weekDay++;
		
			printf("%3d ",dayCount);
	}

	
	printf("\n\t\t--- --- --- --- --- --- ---\n");
	return 0;

}

Your printMonth function is returning 0 when it's declared as returning void - lose it.

Line of code - system("PAUSE") is not portable.

Your range of years is rather odd :-/

If you enter a year outside of your range - besides printing the error message, you also print the top part of your calendar (i.e. the days of the week) - minor logic glitch.

In your output, how about printing a header for the month/year such as AUGUST 2009, prior to printing out the calendar month details?

Your day of week calculation, though it works is probably a tad convoluted with all those century and month table calculations. Here's a short function that returns the day number (assuming Gregorian Calendar). Note, it's a bit quick and dirty and doesn't contain any sanity checks for day and month ranges (although the algorithm still works assuming you understand 43rd August 2009 = 12th September 2009 etc). I'll leave the error checking up to you to code if you wish to use this function.

int getDayNumber(int year, int month, int day) {

    int dayNum;

    if (month < 3) {
        month = month + 12;
        year = year - 1;
    }

    dayNum = (day + (2 * month) + (6 * (month + 1) / 10) + year + (year / 4)
            - (year / 100) + (year / 400) + 1) % 7;
    return dayNum;
}

Not sure what you're asking with reference to DOWHILE usage.

Another "feature" to think about, if no month is entered (or perhaps 0) print out the calendar for the full year.

This question has already been answered. Start a new discussion instead.