/* Series.c */
#include<stdio.h>

main()
{
 int choice;  /* variable for user input */
 int i;       /* variable for loops and output */

 do  /* loop until a valid choice is entered */
  {
   printf("Which series do you wish to display?\n");
   printf("1 - Odd numbers from 1 to 30\n");
   printf("2 - Even numbers from 1 to 30\n");
   printf("3 - All numbers from 1 to 30\n");
   scanf("%d", &choice);  /* get choice from user */
   if ((choice < 1) || (choice > 3))  /* if invalid entry, give message */
    {
     printf("Choice must be 1, 2, or 3\n");
    }
  } while ((choice < 1) || (choice > 3));

  switch (choice)
    {
     case 1:
       for (i = 1; i <= 30; i = i + 2)
         printf("%d ", i);
       printf("\n");
       break;
     case 2:
       for (i = 2; i <= 30; i = i + 2)
         printf("%d ", i);
       printf("\n");
       break;
     case 3:
       for (i = 1; i <= 30; i++)
         printf("%d ", i);
       printf("\n");
       break;
    }
  return 0;
}
