Q:

Write a C program to convert kilograms to pound, and vise versa

0

Write a C program to convert kilograms to pound, and vise versa.

Formula for conversion kg to pounds:

1 kilogram = 2.20462262184878 pounds

Hence, pounds = 2.2 * kilograms

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>

int main()
{

      int choice;
      float kg,pound;
  printf("welcome, what do you want to do?\npress 1 to converto kilograms to pounds\npress 2 to convert pounds to kilograms:");
  scanf("%d",&choice);
  if(choice==1)
  {
  printf("Enter value of Kilograms : ");
  scanf("%f",&kg);
  pound=2.20462262184878*kg;
  printf("\n\t-- Convert Kilograms to pounds --\n");
  printf("\n%f kg = %f pound",kg,pound);
  }
  else{
  printf("Enter value of pounds : ");
  scanf("%f",&pound);
  kg=pound/2.20462262184878;
  printf("\n\t-- Convert pounds to Kilograms--\n");
  printf("\n%f pounds = %f kg",pound,kg);
  
  }
  getch();
  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now