Program to find the number of days in a given month of a given year | faceprep

Program to find the number of days in a given month of a given year | faceprep

Program to find the number of days in a given month of a given year is discussed here. The month and year are given as input, the number of days in that month is displayed as output.

program to find the number of days in a given month


Sample Input:

3

1996

Sample Output:

The number of days is 31


program to find the number of days in a given month of a given year


Algorithm to find the number of days in a given month of a given year

  • Input the month and year from the user.
  • If the year is a leap year and (month == 2), display “Number of days is 29”.
  • Else if (month == 2), display “Number of days is 28”.
  • Else if((month == 1) ||(month == 3 || (month == 5) (month == 7) || (month == 8) || (month == 10) (month == 12)), display “Number of days is 31”.
  • Else, display, “Number of days is 30”.The program to find the number of days in a given month of a given year is given below.

@@coding::1@@


Recommended Programs



Program to find the number of days in a given month of a given year

c