Logo

Programming-Idioms

  • D
  • C

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.

#include <stdio.h>
#include <math.h>
printf("%f %f", pow(a, b), pow(a, n));
  print *,a**b, a**n

** is the exponentiation operator in Fortran.

New implementation...