Get a guaranteed software dev job of ₹5-40 LPA | Apply now for free!

Wipro NLTH Coding Solve | New Year Discount | Codewindow.in

An e-commerce company plans to give their customers a discount for the New Years holiday. The discount will be calculated on the basis of the bill amount of the order placed. The discount amount is the sum of all the odd digits on the customer’s total bill amount. If no odd digit is present in the bill amount, then the discount will be zero. Write an algorithm to find a discount for the given total bill amount.

Input
The input consists of an integer bill amount, representing the customer’s total bill amount.

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

Constraints
0 <billAmount ≤ 109

Example

Input:
2514795

Output:
27

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

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

Also Checkout

Recent Posts