Join Regular Classroom : Visit ClassroomTech

Wipro NLTH Coding Solve | Christmas Discount | Codewindow.in

An e-commerce company plans to give their customers a discount for the Christmas holiday. The discount will be calculated on the basis of the bill amount of the order placed. The discount amount is the product of the sum of all odd digits and the sum of all even digits of the customer’s total bill amount. Write an algorithm to find the discount amount for the given total bill amount.

Input
The input consists of an integer billAmount, representing the total bill amount of a customer.

Output
Print an integer representing the discount amount for the given total bill.

Constraints
O <billAmount≤ 109

Example

Input:
2514795

Output:
162

Explanation:
Odd digits in the given number 2514795 are 5, 1, 7, 9, 5. The sum of these odd digits is 27.
Even digits in the given number 2514795 are 2, 4. The sum of these even digits is 6.
So, the output is 162.

#include<stdio.h>
int main()
{
    long int bill;
    int dis,oddsum=0,evensum=0;
    scanf("%ld",&bill);
    while(bill!=0)
    {
        if(bill%10%2!=0)
            oddsum=oddsum+bill%10;
        else
            evensum=evensum+bill%10;
        bill=bill/10;
    }
    if(oddsum==0)
        oddsum=1;
    if(evensum==0)
        evensum=1;
    
    
    printf("%d",oddsum*evensum);
    return 0;
}

Also Checkout

Recent Posts
Categories
Pages