เป็นโจทย์ที่ได้รับคำขอจากอีเมล์
โจทย์ :ตรวจสอบว่าเดือนดังกล่าวมีกี่วัน โดยใช้ array
แสดงผลการทำงานได้ดังนี้
==========================
Input Month Number: 12
12 is December has 31 day
==========================
หมายเหตุ จากโจทย์ที่รับเฉพาะเดือนเข้ามา ทำให้ไม่สามารถคำนวณได้ว่า ปีนั้น เดือน February มีจำนวนวัน 28 หรือ 29 วันในเดือนดังกล่าว
/*
@Author: Mr.Suppakit Thongdee
@Website: www.sourcecode.in.th
*/
#include <stdio.h>
#include <conio.h>
void main(){
int arrDay[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
char arrMonth[12][20] = {"January","February","March","April",
"May","June","July","August",
"September","October","November","December"};
int iMonth = 0;
clrscr();
printf("Input Month Number:");
scanf("%d",&iMonth);
printf("%d is %s has %d day",iMonth,
arrMonth[iMonth-1],
arrDay[iMonth-1]);
}