-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCost_price.c
47 lines (43 loc) · 1012 Bytes
/
Cost_price.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*WAP to accept Cost Price from user and ask whether the user is a student or not.
If the user is student and cost price is greater than 500, give discount of 10% ELSE discount will be 5%.
If user is not student and cost price is greater 500 then give discount of 8% ELSE discount will be 2%.
(Take all inputs from USER) */
#include<stdio.h>
#include<string.h>
int main()
{
float cp, discount;
char ch;
ch ='y','Y';
printf("Press y or Y if you are a student, else Press n or N key: ");
scanf("%c", &ch);
printf("Enter Cost price: ");
scanf("%f", &cp);
if(ch=='y'|| ch=='Y')
{
if(cp>=500)
{
discount = (cp*10)/100;
printf("Discount of 10 percent is: %.2f", discount);
}
else
{
discount = (cp*5)/100;
printf("Discount of 5per is: %.2f", discount);
}
}
else
{
if(cp>=500)
{
discount = (cp*8)/100;
printf("Discount of 8per is: %.2f", discount);
}
else
{
discount = (cp*2)/100;
printf("Discount of 2per is: %.2f", discount);
}
}
return 0;
}