The following is a perpetual calendar program (single row) implemented in C language (for loop implementation):
Years in the normal int range will not be a problem
#include<stdio.h> #include<Windows.h> intmain() { int i,j,year,day1,mon[12]={31,28,31,30,31,30,31,31,30,31,30,31}; printf("Please enter the year: "); scanf("%d",&year); if(year%4==0&&year%100!=0||year%400==0) { mon[1]=29; } day1=(year+(year-1)/4-(year-1)/100+(year-1)/400)%7; for(j=0;j<12;j++) { printf("\n************************\n%d month\n day 123456\n",j+1); for(i=0;i<day1;i++) { printf(" "); } for(i=1;i<=mon[j];i++) { printf("%3d",i); if((i+day1-1)%7==6) { printf("\n"); } } day1=(day1+mon[d])%7; } system("pause"); }
Click the link below to view the n-row perpetual calendar
Click to open the n-row perpetual calendar