-
Language
C
-
Description
It accepts the number of the month in a year and returns the number of days in that month.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int number_of_days, number_of_the_month;
printf ("Enter the value of number of the month: ");
scanf ("%d", &number_of_the_month);
(void) getchar ();
number_of_days=0;
if(number_of_the_month==2)
number_of_days=28;
if(number_of_the_month==1||number_of_the_month==3||number_of_the_month==5||number_of_the_month==7||number_of_the_month==8||number_of_the_month==10||number_of_the_month==12)
number_of_days=31;
if(number_of_the_month==4||number_of_the_month==6||number_of_the_month==9||number_of_the_month==11)
number_of_days=30;
if(number_of_the_month<1||number_of_the_month>12)
printf ("Wrong month number\n");
printf ("Value of number of days: %d\n", number_of_days);
putchar ('\n');
system ("pause");
return EXIT_SUCCESS;
}
#include <stdlib.h>
int main (void)
{
int number_of_days, number_of_the_month;
printf ("Enter the value of number of the month: ");
scanf ("%d", &number_of_the_month);
(void) getchar ();
number_of_days=0;
if(number_of_the_month==2)
number_of_days=28;
if(number_of_the_month==1||number_of_the_month==3||number_of_the_month==5||number_of_the_month==7||number_of_the_month==8||number_of_the_month==10||number_of_the_month==12)
number_of_days=31;
if(number_of_the_month==4||number_of_the_month==6||number_of_the_month==9||number_of_the_month==11)
number_of_days=30;
if(number_of_the_month<1||number_of_the_month>12)
printf ("Wrong month number\n");
printf ("Value of number of days: %d\n", number_of_days);
putchar ('\n');
system ("pause");
return EXIT_SUCCESS;
}