1.

Write a program to input the number of a month ( 1 for January, 2 for February and so on). Depending on the number, display the number of days in that month. Assume the year is a leap year.

Answer»

Program to find the number of days in a given MONTH of a given year is given below.C C++ Java Python 31 // C program to find the number of days in a given month23#include4int main()5{6 //fill the code7 int year, month;8 scanf("%d %d",&month,&year);9 if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)10 printf("Number of days is 31");11 else if((month == 2) && ((year%400==0) || (year%4==0 && year%100!=0))) 12 {13 printf("Number of days is 29");14 }15 else if(month == 2)16 {17 printf("Number of days is 28");18 } 19 else20 printf("Number of days is 30");21 return 0;22}Output31996Number of days is 31



Discussion

No Comment Found