Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
  5. C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. #include <stdio.h>
  10.  
  11. float calculate(float price, float percentage)
  12. {
  13.     return (price*percentage)/100 ;
  14. }
  15.  
  16.  
  17. int main()
  18. {
  19.     // מחיר המוצר
  20.     float item_price;
  21.    
  22.     // אחוז ההנחה
  23.     float discount_p;
  24.    
  25.     // הצגת הודעה למשתמש
  26.     printf("Please enter item price: ");
  27.    
  28.     // קליטת ערכים מהמשתמש
  29.     scanf("%f",&item_price);
  30.    
  31.     // הצגת הודעה למשתמש
  32.     printf("\nPlease enter discount percentage: ");
  33.    
  34.     // קליטת אחוז הנחה מהמשתמש
  35.     scanf("%f",&discount_p);
  36.    
  37.     // חישוב אחרי ההנחה
  38.     float item_after_discount = item_price - calculate(item_price, discount_p);
  39.    
  40.     // חישוב אחרי התייקרות
  41.     float item_after_adding = item_price + calculate(item_price, discount_p);
  42.    
  43.     // הצגה של המחירים
  44.     printf("Item Price: %f \n", item_price);
  45.    
  46.     printf("Item Price after discount: %f \n", item_after_discount);
  47.     printf("Item Price after adding: %f \n", item_after_adding);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement