Logo

Programming-Idioms

  • Pascal
  • Fortran

Idiom #305 Calculate exponentiation of real numbers

Compute and print a^b, and a^n, where a and b are floating point numbers and n is an integer.

  print *,a**b, a**n

** is the exponentiation operator in Fortran.
math
writeln('a^b=',power(a,b));
writeln('a^n=',power(a,n));
#include <stdio.h>
#include <math.h>
printf("%f %f", pow(a, b), pow(a, n));

New implementation...