Advertisement
yoyo106

Discount elseif

Mar 19th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int q;
  7.     float d,u,p;
  8.     printf("Enter quantity: \n");
  9.     scanf("%d",&q);
  10.     printf("Enter discount type: \n");
  11.     scanf("%f",&d);
  12.     printf("Enter unit price: \n");
  13.     scanf("%f",&u);
  14.     if (d==1){
  15.     p=q*u*0.90;
  16.     }
  17.     else if (d==2){
  18.                 p=q*u*0.85;
  19.         }
  20.     else
  21.         {
  22.             p=q*u*0.95;
  23.         }
  24.                 printf("Price is %f",p);
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement