Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int x;
- float price;
- char y;
- printf("Please enter price of product (RM) and discount colour code (R, G or B):\n");
- scanf ("%d%c",&x,&y);
- printf("RM %d\n",x);
- if ( y== 'r' || y== 'R')
- {
- price= x-(x*0.20);
- printf("The actual price is RM%.2f\n", price);
- }
- else if ( y== 'g' || y== 'G')
- {
- price= x-(x*0.15);
- printf("The actual price is RM%.2f\n",price);
- }
- else if ( y== 'b' || y== 'B')
- {
- price= x-(x*0.10);
- printf("The actual price is RM%.2f\n",price);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment