answersLogoWhite

0


Best Answer

#include<stdio.h>

#define TRUE 1

#define FALSE 0

int days_in_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

char *months[]=

{

" ",

"\n\n\nJanuary",

"\n\n\nFebruary",

"\n\n\nMarch",

"\n\n\nApril",

"\n\n\nMay",

"\n\n\nJune",

"\n\n\nJuly",

"\n\n\nAugust",

"\n\n\nSeptember",

"\n\n\nOctober",

"\n\n\nNovember",

"\n\n\nDecember"

};

int inputyear(void)

{

int year;

printf("Please enter a year (example: 1999) : ");

scanf("%d", &year);

return year;

}

int determinedaycode(int year)

{

int daycode;

int d1, d2, d3;

d1 = (year - 1.)/ 4.0;

d2 = (year - 1.)/ 100.;

d3 = (year - 1.)/ 400.;

daycode = (year + d1 - d2 + d3) %7;

return daycode;

}

int determineleapyear(int year)

{

if(year% 4 FALSE)

{

days_in_month[2] = 29;

return TRUE;

}

else

{

days_in_month[2] = 28;

return FALSE;

}

}

void calendar(int year, int daycode)

{

int month, day;

for ( month = 1; month <= 12; month++ )

{

printf("%s", months[month]);

printf("\n\nSun Mon Tue Wed Thu Fri Sat\n" );

// Correct the position for the first date

for ( day = 1; day <= 1 + daycode * 5; day++ )

{

printf(" ");

}

// Print all the dates for one month

for ( day = 1; day <= days_in_month[month]; day++ )

{

printf("%2d", day );

// Is day before Sat? Else start next line Sun.

if ( ( day + daycode ) % 7 > 0 )

printf(" " );

else

printf("\n " );

}

// Set position for next month

daycode = ( daycode + days_in_month[month] ) % 7;

}

}

int main(void)

{

int year, daycode, leapyear;

year = inputyear();

daycode = determinedaycode(year);

determineleapyear(year);

calendar(year, daycode);

printf("\n");

}

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you wrte aC program to print calendar?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you wrte aC program in Linux?

OK. Done that


24W on an AC?

24 Windows on an Advent Calendar


24 w on an ac?

How about 24 windows on an advent calendar - or 24 wheels on an amoured car?


What does AC and AD stand for in calendar terms?

Are you asking what BC and AD are, they are Before Christand the Latin phrase Anno Domini meaning Year of the Lord, never heard of AC on calendars.


How to write aC program to merge two singly linked list?

write a c program to circular queue


How do you wrte ac program of 2's complement?

#include &lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;process.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; #define pf printf void main() { int a[],b[],i,len,j; clrscr(); pf("\nenter the binary number:"); gets(a); len=strlen(a); for(i=0;i&lt;len;i++) { if(a[i]==0a[i]==1) continue; else { pf("\nenter correctly"); exit(0); } strcpy(b,a); for(


Write a pascal program that compute an area of a triangle?

{A program to compute the area of a triangle} {by Ogboin W. Meshach} Var; b,h:real; BEGIN Writeln('Triangle'); Write('Base: '); Readln(base); Write('Height: '); Readln(height); area:=0.5*base*height; Writeln('Area: ', area :0:2); End.


Who is ac the program director?

DJ A.C. The Program Director is the author and founder of HipHopPhilosophy.com, HipHopPhilosophy.com Radio, and HipHopPhilosophy.com Radio clothing.


AC Moore?

form_title= AC Moore form_header= Find all your crafting supplies at AC Moore. What type of project are you creating?*= _ [50] What supplies do you need?*= _ [50] Are you a part of the rewards program?*= () Yes () No


How do you recharge ac on Ford escape 2001?

I need a step by step print out of how to recharge my 2001 Ford Escape XLT. I plan on refilling with R-134 Freon. Can you help me?


How do you wrte ac programe for factorial?

#include &lt;stdio.h&gt; int main() { int fact=1,num; printf("Enter number: "); scanf("%d",&amp;num); if((num==0) (num==1)) { printf("Factorial = %d",fact); return 0; } else { while(num!=1) { fact=fact*num; num--; } printf("Factorial = %d",fact); return 0; } }


Do air conditioners run on gas?

I once worked on a 318 Chrysler V-8 which ran on Natural Gas that drove an 80 ton AC compressor and cooled a print shop, Real pig...