C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting
C > Beginners Lab Assignments sample source codes
Calender
Calender #include"stdio.h" #include"conio.h" #include
#include
#include
int month(int,int,int); int yea(int); void cal(int,int); void print(int,int); void main() { int g,year,h; char ch,mu='y'; clrscr(); mos: clrscr(); cout<<" INSTRUCTION FOR FINDING MONTH OF ANY YEAR"; cout<<" ENTER MONTH IN LETTER AND YEAR ONWARDS 0000"; cout<<" CALENDER"; printf(" PLEASE ENTER MONTH:="); scanf("%d",&g); printf(" NOW ENTER YEAR:="); scanf("%d",&year); printf(" FIND"); for(h=0;h<=3;h++) { printf(" ."); delay(100); } cal(g,year); while(mu=='y') { ch=getch(); if(ch=='n') { if(g==12) { year+=1; g=1; cal(g,year); } g+=1; cal(g,year); } else if(ch=='p') { if(g==1) { year-=1; g=13; cal(g,year); } g-=1; cal(g,year); } else if(ch=='m') { year+=1; cal(g,year); } else if(ch=='b') { year-=1; cal(g,year); } else if(ch=='c') goto mos; else if(ch=='q') { exit(0); } } fflush(stdin); getch(); } void cal(int g,int year) { int n,o,i; clrscr(); cout<<" TO FIND NEXT YEAR PRESS M"; cout<<" TO FIND PREVIOUS YEAR PRESS B"; cout<<" TO FIND NEXT MONTH PRESS N"; cout<<" TO FIND PREVIOUS MONTH PRESS P"; cout<<" TO EXIT PRESS Q"; printf(" MONTH %d",g); printf(" YEAR %d",year); n=yea(year); o=month(g,year,n); if((g==1)||(g==3)||(g==5)||(g==7)||(g==8)||(g==10)||(g==12)) { print(31,o); } else if((g==4)||(g==6)||(g==9)||(g==11)) { print(30,o); } else if(g==2) { if(year%4==0) print(29,o); else print(28,o); } } int yea(int year) { int i,k,n; unsigned long int m,j; for(i=0;i
Privacy Policy
|
Link to Us
|
Links