Advertisement
dllbridge

Untitled

May 2nd, 2021
953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1.  
  2. #include  <stdio.h>
  3.  
  4.  
  5. int calc_price(int);
  6.  
  7.  
  8.  
  9. ///////////////////////////////////////////////////////////////////
  10. int main()                                                       //
  11. {
  12.    
  13.     for(int i = 1; i <= 10; i++)
  14.     {
  15.         printf("price of %2d books is %5d\n", i, calc_price(i));
  16.     }
  17.        
  18. return 0;
  19. }
  20.  
  21.  
  22. ///////////////////////////////////////////////////////////////////
  23. int calc_price(int num_of_books)                                 //
  24. {
  25.  
  26.         int     i = 0,
  27.             price = 0;
  28.        
  29.         for(i; i < num_of_books; i++)
  30.         {
  31.             price += 1000 - 55 * (i % 7);
  32.         }
  33.        
  34. return price;
  35. }
  36.  
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement