function polynomial_print ( c )

%*****************************************************************************80
%
%% polynomial_print() prints a polynomial.
%
%  Discussion:
%
%    The power sum form is:
%
%      p(x) = c(0) + c(1)*x + ... + c(n-1)*x^(n-1) + c(n)*x^(n)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer C(1:N+1): the polynomial coefficients.
%
  if ( all ( c == 0 ) )
    fprintf ( '0\n' );
    return
  end

  n = polynomial_degree ( c );

  for i = n : -1 : 0

    if ( c(i+1) < 0.0 )
      plus_minus = '-';
    elseif ( i < n )
      plus_minus = '+';
    else
      plus_minus = '';
    end

    mag = abs ( c(i+1) );
%
%  Don't print terms with a zero coefficient.
%
    if ( mag ~= 0 )
%
%  Don't print a coefficient of 1.
%
      if ( mag == 1 )

        if ( 2 <= i )
          fprintf ( 1, '%cx^%d', plus_minus, i );
        elseif ( i == 1 )
          fprintf ( 1, '%cx', plus_minus );
        elseif ( i == 0 )
          fprintf ( 1, '%c%d', plus_minus, mag );
        end

      else

        if ( 2 <= i )
          fprintf ( 1, '%c%d*x^%d', plus_minus, mag, i );
        elseif ( i == 1 )
          fprintf ( 1, '%c%d*x', plus_minus, mag );
        elseif ( i == 0 )
          fprintf ( 1, '%c%d', plus_minus, mag );
        end

      end

    end

  end

  fprintf ( 1, '\n' );

  return
end
