// 08262009b.cpp
//
// Peter H. Anderson, MSU, Aug 26, '09

#include <stdio.h>
#include <stdlib.h>

int main()
{     
   int val, th, hu, te, un, month; 
   
   while(1)
   {
      printf("Enter a four digit num: ");
      scanf("%d", &val);
      
      if (val < 0)
      {
         break;
      }
      // else
      th = val / 1000;
      val = val % 1000;
      hu = val / 100;
      val = val % 100;
      te = val / 10;
      val = val % 10;
      un = val;
   
      printf("%d    %d    %d    %d\n", th, hu, te, un);
    }
   
   system("pause");
      
   while(1)
   {
      printf("Enter the number of a month: ");
      scanf("%d", &month);
      
      if (month < 0)
      {
         break;
      }   
      // else
      
      switch(month)
      {
        case 1:  printf("Jan\n"); 
                 break;
        case 2:  printf("Feb\n"); 
                 break;
        case 3:  printf("Mar\n"); 
                 break;
        // ... 4, 5, 6, 7, 8, 9, 10, 11
        case 12:  printf("Dec\n"); 
                  break;
        default:
                  printf("Unknown\n"); 
                  break;
      }
   }           
   system("pause");
}                                         
  
#ifdef OUTPUT  
Enter a four digit num: 1234
1    2    3    4
Enter a four digit num: 9812
9    8    1    2
Enter a four digit num: -1
Press any key to continue . . .
Enter the number of a month: 2
Feb
Enter the number of a month: 5
Unknown
Enter the number of a month: 12
Dec
Enter the number of a month: -1
Press any key to continue . . .
#endif