Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <math.h>
  5.  
  6. float unit_price(const float pack_price, const int rolls_count, const int pieces_count);
  7.  
  8. int main() {
  9.     printf("%.4f\n", unit_price(5.63, 20, 200));
  10.     //printf("%.4f\n", unit_price(4.79, 16, 150));
  11.     return 0;
  12. }
  13.  
  14. float unit_price(const float pack_price, const int rolls_count, const int pieces_count) {
  15.     float result;
  16.     result = (pack_price*100)/(rolls_count*pieces_count);
  17.     result = result*100;
  18.     result = round(result);
  19.     result = result/100;
  20.     return result;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement