Passing double value to a function in C

By: Emiley J Emailed: 1786 times Printed: 2623 times    

This sample program in C demonstrates the concept of passing a double value to a function as parameter. The program accepts a number in feet and converts the feet into meters by using a conversion function.

#include 

double feet_to_meter(double f);

int main(void)
{
  double feet;

  printf("Enter feet: ");
  scanf("%lf", &feet);
  printf("Meters: %f", feet_to_meter(feet));

  return 0;
}

double feet_to_meter(double f)
{
  return f / 3.28;
}

Most Viewed Articles (in C )

Latest Articles (in C)

Comment on this tutorial