
/* Example: simple functions */
/* Function with multiple return statements */

#include <stdio.h>

int pins(int tn);  /* IC pins lookup */

main()
{
  int ic, p;
  
  printf("Enter an IC type number: ");
  scanf("%i", &ic);
  
  p = pins(ic);
  
  if (p==0)
    printf("IC type %i is not recognised.\n", ic);
  else
    printf("IC type %i has %i pins.\n", ic, p);
}


int pins(int tn)  /* IC pins lookup */
{
  /* Returns the number of pins for an IC of type number tn. 
  If the type is not recognised, returns zero. */
  
  switch (tn)
  {
    case 555: case 741: case 748: 
      return 8;
    case 556: case 7400: case 7414:
      return 14;
    case 7448: case 7485:
      return 16;
    case 6502: case 6800: case 8085: case 8088: 
      return 40;
    default:
      return 0; /* easily tested */
  }
}
