/***********************************************************************/
/* PROGRAM TO VERIFY VALIDITY OF DATE */
/* AUTHOR : DEEPAK MAHAKALE 3 YEAR IT SRCOEM */
/* BLOG : www.mahakaledeepak.blogspot.com */
/***********************************************************************/
#include<stdio.h>
#include<conio.h>
void main() {
int d, m, y, y_i = 0, d_i = 0, leap = 0, i, d_l = 0;
clrscr();
printf("\n\t PROGRAM TO VERIFY VALIDITY OF DATE ");
printf("\n\n\t Enter the date (dd mm yyyy) : ");
scanf(" %d %d %d", & d, & m, & y);
if (y < 1600 || y > 2100) // Change this range acc. to you...
{
printf("\n\t Year invalid..");
y_i = 1;
} else {
printf("\n\t Year valid..");
}
if (y_i != 1) {
if (y % 4 == 0)
leap = 1;
}
if (m < 1 || m > 12) {
printf("\n\t Month invalid..");
} else {
printf("\n\t Month valid..");
}
if (d < 1 || d > 31) {
d_i = 1;
}
if (m >= 1 && m <= 7) {
for (i = 1; i <= 6; i++) {
if (m % 2 == 0)
d_l = 30;
if (m % 2 == 1)
d_l = 31;
}
}
if (leap == 0 && m == 2) {
d_l = 28;
}
if (leap == 1 && m == 2) {
d_l = 29;
}
if (m >= 8 && m <= 12) {
for (i = 7; i <= 12; i++) {
if (m % 2 == 0)
d_l = 31;
if (m % 2 == 1)
d_l = 30;
}
}
if (d > d_l)
d_i = 1;
if (d_i == 1)
printf("\n\t Date invalid..");
if (d_i == 0)
printf("\n\t Date valid..");
printf("\n\n\n\t BY - DEEPAK MAHAKALE");
getch();
}
Amazon banner
Sunday, 16 September 2012
PROGRAM TO VERIFY VALIDITY OF DATE
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment