#include<stdio.h>
int calculateDiscount(int billAmount){
int bill_amount=billAmount;
int sumOddDigits=0;
int sumEvenDigits =0;
while(bill_amount>0)
{
int digit=bill_amount%10;
if(digit%2==0){
sumEvenDigits+=digit;
}else{
sumOddDigits+=digit;
}
bill_amount=bill_amount/10;
}
return sumOddDigits*sumEvenDigits;
}
int main(){
int billAmount=0;
int discount=0;
int totalBill=0;
printf("Enter the bill amount: ");
scanf("%d",&billAmount);
discount=calculateDiscount(billAmount);
totalBill=discount+billAmount;
printf("\nDiscount is: %d\n",discount);
printf("The total bill is: %d\n",totalBill);
scanf("%d",&billAmount);
return 0;
}
Comments
Leave a comment