Passing double value to a function in C

By: Emiley J Printer Friendly Format    

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.


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