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
|
#include <stdio.h>
char *years[4] = {
"Freshman", "Sophomore", "Junior", "Senior"
};
char *months[12] = {
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
};
char *days[7] = {
"Sunday", "Monday", "Tuesday", "Wedensday",
"Thursday", "Friday", "Saturday"
};
int main(int argc, char **argv)
{
int number = 5; // an illegal value
int choice = -1;
// Get the input
printf("Please select:\n"
"1 - Year\n"
"2 - Day\n"
"3 - Month\n"
"Input choice: ");
fflush(stdout);
scanf("%d", &choice);
printf("Input Number: ");
fflush(stdout);
scanf("%d", &number);
// Do something with the input
switch(choice) {
case 1: // year
if (number < 1 || number > 4) {
printf("illegal number\n");
} else {
printf("%s\n", years[number-1]);
}
break;
case 2:
break;
case 3:
break;
default:
break;
}
return 0;
}
|