This blog is under construction

Sunday, 7 July 2013

C program to convert pounds to kilograms

Write a C program to convert pounds to kilograms.

  #include <stdio.h>
  #define POUNDTOKG 0.453592
  int main() {
        float pound, kilogram;

        /* get the input from the user */
        printf("Enter weight in pound:");
        scanf("%f", &pound);

        /* converting pound to kilogram */
        kilogram = pound * POUNDTOKG;

        /* printing the output */
        printf("%.2f pound = %.2f KiloGram\n", pound, kilogram);
        return 0;

  jp@jp-VirtualBox:~/$ ./a.out
  Enter weight in pound:2.20462
  2.20 pound = 1.00 KiloGram

See Also:

No comments:

Post a Comment