
7-19
Arrays
# include <process.h>
void main()
{
int month[12]={1,3,5,7,8,10,12,4,6,9,11,2};
int i,mn;
clrscr();
printf(“Enter Number of Month :”);
scanf(“%d”,&mn);
for(i=0;i<=11;i++)
{
if(mn==month[i])
goto compare;
}
printf(“\n Invalid Month”);
exit(1);
compare:;
if(i+1==12)
printf(“Month (%d) Contains 28 days.”,month[i]);
if(i+1<8)
printf(“Month (%d) Contains 31 days.”,month[i]);
if(i+1>7 && i+1!=12)
printf(“Month (%d) Contains 30 days.”,month[i]);
getche();
}
OUTPUT:
Enter Number of Month : 2
Month (2) Contains 28 days.
Explanation:
is program is slightly dierent as compared to the ...