Programming Tutorials

Passing double value to a function in C

By: Emiley J in C Tutorials on 2010-04-16  

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 <stdio.h>

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;
}






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in C )

Latest Articles (in C)