/* a program that performs simple operations */
int main(int ac, char **av)
{
    int (*operation)(int, int);
    int first_number;
    int second_number;
    char symbol;
    int result;

    if (!check_arguments_valid(ac) ||
            !check_if_number(av[1]) ||
            !check_if_number(av[3]) ||
            !check_if_symbol(av[2]))
    {
        printf("Program exiting.\n");
        return (1);
    }

    first_number = atoi(av[1]);
    second_number = atoi(av[3]);
    symbol = av[2][0];

    /* select the appropriate function based on the operator symbol */
    operation = get_op_func(symbol);
    result = (*operation)(first_number, second_number);

    printf("%d\n", result);

    return (0);
}
int main(int ac, char **av){
  if (ac==4){
    int (*p)(int,int);
    p=*get_op_func(*av[2]);
    if (*p!=NULL){
      print_number( (*p)(atoi(av[1]), atoi(av[3])) );
      print_char('\n');
      return 0;
    }
  }
  return 1;
}
int main(int argc, char *argv[])
{
  int i;
  int (*op_func) (int, int);
  if (argc != 4) return 1;

  op_func = get_op_func(*argv[2]);
  if (op_func == 0) return 2;
  i = op_func(atoi(argv[1]), atoi(argv[3]));
  printf("%d\n", i);

  return 0;
}
int main(int argc, char *argv[]) 
{
	if (argc != 4) {
		return 1; /* expects program name, value, operator, and another value. 1 = error */
	}

	op_func = get_op_func(*argv[2]); 

	if (op_func == 0) {
		return 2;
	}

	int i;
	i = op_func(atoi(argv[1]), atoi(argv[3]));
	printf("%d\n", i);
	return 0;
}
int main(int ac, char ** av) {
  int num1, num2, answer;
  if (ac != 4) {
   return 1;
  }
  else if (av[2][0] != '+' && av[2][0] != '-' && av[2][0] != '*' && av[2][0] != '/' && av[2][0] != '%') {
    return 1;
  }
  else if (av[2][1] != '\0') {
    return 1;
  }
  else {
    num1 = atoi(av[1]);
    num2 = atoi(av[3]);
    answer = (get_op_func(av[2][0]))(num1, num2);
    print_number(answer);
    print_char('\n');
    }
  return 0;
}
int main(int ac, char **av)
{
  int n;

  int (*op_func)(int a, int b);

  if (ac != 4)
    {
      return 1;
    }
  op_func = get_op_func(*av[2]);
  if (op_func == 0)
    {
      return 1;
    }
  n = op_func(atoi(av[1]), (atoi(av[3])));
  print_number(n);
  print_char('\n');
  return 0;
}
int main(int argc, char *argv[]) {
  int x, y, z;
  char c;
 
  while (argc == 4 && argv[2][1] == '\0') {
    c = argv[2][0];
    while (c == '+' || c == '-' || c == '*' || c == '/' || c == '%') {
      x = atoi(argv[1]);
      y = atoi(argv[3]);
      c = argv[2][0];
      
      z = get_op_func(c)(x,y);
      
      print_number(z);
      print_char('\n');
      return (0);
    }
    return (1);
  }
  return (1);
}
/* ======================================================================= *
 *    This function parse the command-line arguments to retrieve the       * 
 *    operands and the operator                                            *
 * ======================================================================= */
int main(int argc, char *argv[]){
    if (argc != 4 || *get_op_func(*argv[2]) == (NULL)) return 1;
    printf("%d\n", (*get_op_func(*argv[2]))(atoi(argv[1]), atoi(argv[3])));
    return 0;
}