-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path8_Question.cpp
More file actions
35 lines (26 loc) · 814 Bytes
/
8_Question.cpp
File metadata and controls
35 lines (26 loc) · 814 Bytes
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
// A supermarket maintains a pricing format for all its products. A value N is printed on each product.
// When the scanner reads the value N on the item,the product of all the digits in the value N is the price of the item.
// The task here is to design the software such that given the code of any item N the product (multiplication) of all the
// digits of value should be computed(price).
// Example 1:
// Input : 5244 -> Value of N
// Output : 160 -> Price
// Explanation: From the input above
// Product of the digits 5,2,4,4
// 5*2*4*4= 160
// Hence, output is 160.
#include<iostream>
using namespace std;
int CalculatePrice(int N){
int prod = 1;
while(N){
prod *= N % 10;
N /= 10;
}
return prod;
}
int main(){
int N;
cin>>N;
cout<<CalculatePrice(N);
}