Skip to content

Commit 939c954

Browse files
authored
Create Buy Please.c
1 parent 6d7e6fa commit 939c954

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Chef went to a shop and buys a pens and b pencils. Each pen costs x units and each pencil costs y units. Now find what is the total amount Chef will spend to buy a pens and b pencils.
2+
3+
Input:
4+
First-line will contain 4 space separated integers a, b, x and y respectively.
5+
Output:
6+
Print the answer in a new line.
7+
8+
Constraints
9+
1≤a,b,x,y≤103
10+
Sample Input 1:
11+
2 4 4 5
12+
Sample Output 1:
13+
28
14+
Sample Input 2:
15+
1 1 4 8
16+
Sample Output 2:
17+
12
18+
EXPLANATION:
19+
In the first example, total cost is (2 * 4 + 4 * 5) = 28.
20+
In the second example, total cost is (1 * 4 + 1 * 8) = 12. */
21+
22+
23+
#include <stdio.h>
24+
25+
int main(void) {
26+
27+
int a,b,x,y;
28+
scanf("%d %d %d %d",&a,&b,&x,&y);
29+
int pen_cost= a*x;
30+
int pencil_cost=b*y;
31+
int total=pen_cost+pencil_cost;
32+
printf("%d",total);
33+
34+
return 0;
35+
36+
}

0 commit comments

Comments
 (0)