I am brushing up on my C and to do that, I was attempting the following problem. I have also provided my proposed solution. It'll work when I write it as a one pass solution but not I write in the while loop (I wanted to write the code to be where I could keep prompting the user for numbers until they quit). I am getting the Runtime error 153. Thx.
Write a C program that reads an integer between 1 and 12 and print the month of the year in English. Test Data : Input a number between 1 to 12 to get the month name: 8 Expected Output: August
#include <stdio.h>
int main(void){
int int1 = 0;
printf ("Enter a number between 1-12 to get a month. Enter 13 to quit. \n");
scanf ("%d", &int1);
char ch_arr[12][10] =
{
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
while (int1 < 13)
{
printf ("Your month is %s \n", ch_arr +int1 );
scanf ("%d", &int1);
}
return 0;
}