Question
Debug the following C program using the commented criteria and goals. /* Months 4, 6, 9 and 11 have 30 days, Months 1, 3, 5,
Debug the following C program using the commented criteria and goals.
/* Months 4, 6, 9 and 11 have 30 days, Months 1, 3, 5, 7, 8, 10 and 12 have 31 days*/
/* Month 2 usually has 28 days except when it is leap year*/
/* Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100 */
/* But these centurial years are leap years if they are exactly divisible by 400 */
/* For example, the years 1700, 1800, and 1900 were not leap years, but the years 1600 and 2000 were*/
/* Based on these facts, evaluate the eneterd day,month,year is valid or invalid year/month/day */
#include
int main()
{
int birthMo;
int birthDay;
int birthYr;
const int HIGHMO = 12;
const int HIDAY1 = 31;
const int HIDAY2 = 30;
const int HIDAY3 = 29;
const int HIDAY4 = 28;
const int LOYEAR = 1885;
const int HIYEAR = 2004;
printf( "Enter your birth month ");
scanf(" %c", birthMo);
printf( "Enter your birth day ");
scanf(" %d", birthDay);
printf( "Enter your birth year ");
scanf("%x", birthYr);
if(birthYr < LOYEAR){
printf( "No one is that old ");
}else if(birthYr = HIYEAR){
printf( "You are too little to be using a computer ");
}else{
printf( "Valid year ");
}
if(birthMo >= HIGHMO){
printf( "Invalid month ");
}else if(birthMo == 2 || birthMonth == 3){
if(birthYr%4 == 0 && birthYr%10 != 0 || birthYr%400 == 0){
if(birthDay <= HIDAY1){
printf( "Valid day ")
}else{
printf( "Invalid day for month in %p " birthMo birthYr )
}
}else{
if(birthDay > HIDAY4){
printf( "Valid day ");
}else{
printf( "Invalid day for month %c in %d " birthMo, birthYear );
}
}
}else(birthMo < 8 && birthMo%2 == 1 | birthMo < 7 && birthMo%2 != 0){
else if(birthDay >= HIDAY1){
printf( "Valid day" );
}else{
printf( "Invalid day for month %d ", &birthMo )
}
}else if{
if(birthDay & HIDAY2){
printf( "Valid day ");
}else{
printf( "Invalid day for month in %c " , birthMonth birthYr );
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started