C program to enter month number and print number of days in month.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

C program to enter month number and print number of days in month.. I have used DEV-C++ compiler for debugging purpose. But you can use any C programming language compiler as per your availability.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
 
int main()
{
    int month;
    
    printf("Enter month number (1-12): ");
    scanf("%d", &month); 
 
    if(month == 1)
    {
        printf("Enter month : January \nNo. of days : 31 days");
    }
    else if(month == 2)
    {
    	printf("Enter month : February \nNo. of days : 28 or 29 days");        
    }
    else if(month == 3)
    {
    	printf("Enter month : March \nNo. of days : 31 days");        
    }
    else if(month == 4)
    {
    	printf("Enter month : April \nNo. of days : 30 days");        
    }
    else if(month == 5)
    {
    	printf("Enter month : May \nNo. of days : 31 days");
    }
    else if(month == 6)
    {
    	printf("Enter month : June \nNo. of days : 30 days");        
    }
    else if(month == 7)
    {
    	printf("Enter month : July \nNo. of days : 31 days");        
    }
    else if(month == 8)
    {
        printf("Enter month : August \nNo. of days : 31 days");
    }
    else if(month == 9)
    {
        printf("Enter month : September \nNo. of days : 30 days");
    }
    else if(month == 10)
    {
       printf("Enter month : October \nNo. of days : 31 days");
    }
    else if(month == 11)
    {
        printf("Enter month : November \nNo. of days : 30 days");
    }
    else if(month == 12)
    {
        printf("Enter month : December \nNo. of days : 31 days");;
    }
    else
    {
        printf("Invalid input! Please enter month number between (1-12).");
    }
 
    return 0;
}

Result

C language techstudy.org

     






Related Topics




Popular Posts