Use the switch statement to program, determine whether a leap year is based on the years entered, and determine how many days of the month, based on the month entered

Source: Internet
Author: User

#include <stdio.h>
int main ()
{
int year, month, flag = 0;
printf ("Enter Year and month:!\n");
scanf ("%d%d", &year, &month);
If (year% of 4 ==0 && year%!! = 0 | | Year% 400 ==0)
{
flag = 1;
printf ("The year you entered is a leap years \ n");
}
Else
{
Flag = 0;
printf ("The age you entered is common year!! \ n ");

}
Switch (month)
{
Case 1:
printf ("You entered a total of 31 days in January \ n");
Break
Case 2:
if (flag = = 1)
printf ("You entered a total of 29 days in February \ n");
Else
printf ("You entered a total of 28 days in February \ n");
Break
Case 3:
printf ("You entered a total of 31 days in March \ n");
Break

Case 4:
printf ("You entered a total of 30 days in April \ n");
Break
Case 5:
printf ("You entered a total of 31 days in May \ n");
Break
Case 6:
printf ("You entered a total of 30 days in June \ n");
Break
Case 7:
printf ("You entered a total of 31 days in July \ n");
Break
Case 8:
printf ("You entered a total of 31 days in August \ n");
Break
Case 9:
printf ("You entered a total of 30 days in September \ n");
Break
Case 10:
printf ("You entered a total of 31 days in October \ n");
Break
Case 11:
printf ("You entered a total of 30 days in November \ n");
Break
Case 12:
printf ("You entered a total of 31 days in December \ n");
Break

}
return 0;
}

Use the switch statement to program, determine whether a leap year is based on the years entered, and determine how many days of the month, based on the month entered

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.