sanjay555

Untitled

May 28th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. //
  2. // Created by sanjayshr on 24/5/17.
  3. //
  4. /*
  5.  *
  6.  * Lbs to Kg
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. struct Weight
  13. {
  14.     float OneLbsinKg;
  15.  
  16. };
  17.  
  18. float weightConverter(float* lbss, struct Weight * POneLbsinKg)
  19. {
  20.     float result;
  21.     POneLbsinKg -> OneLbsinKg = 0.453592;
  22.     result = *lbss * POneLbsinKg->OneLbsinKg;
  23.     return result;
  24. }
  25.  
  26. int main()
  27. {
  28.     float lbs;
  29.     float OneLbsin_Kg;
  30.  
  31.     struct Weight * PWeight = (struct Weight *) malloc(sizeof(struct Weight));
  32.     printf("Enter weight in lbs :");
  33.     scanf("%f", &lbs);
  34.     if (weightConverter(&lbs, PWeight))
  35.     {
  36.         printf("1 Lbs : %f \n", PWeight->OneLbsinKg);
  37.         printf("%f \n", weightConverter(&lbs,PWeight));
  38.  
  39.     }
  40.     free(PWeight);
  41. }
Add Comment
Please, Sign In to add comment