/* 

  POWER0.C : A C program for testing a power()
             function.

  Barry McMullin
  8th February 1996.

*/

#include <safe-c.h>

void put_floating_point(floating_point_type number)
{
  string_type s;

  floating_point_to_string(s, number);
  put_string(s);
}

floating_point_type get_floating_point(void)
{
  string_type s;

  get_string(s);
  return (string_to_floating_point(s));
}

integer_type get_integer(void)
{
  string_type s;

  get_string(s);
  return (string_to_integer(s));
}



floating_point_type power(floating_point_type x, integer_type n)
{
 floating_point_type c;
 
 c = 1;
 while(n > 0)
 {
  n--;
  c = (c*x);
 }

 return(c);
}

void main(void)
{
  integer_type n;
  floating_point_type x;

  put_string("Welcome to POWER0.C\n");
  put_string("Please enter x: ");
  x = get_floating_point();
  put_string("Please enter n:");
  n = get_integer();

  put_string("power(x,n) = ");
  put_floating_point(power(x,n));

  put_string("\n\nBye from POWER0.C\n\n");
}
