Answer to Question #290957 in C for Keerthi

Question #290957

An E-Commerce commerce company plans to give their customers a discount for the New Years holiday. The discount will be calculated based on the bill amount of the order placed. The discount amount is the product of the sum of all odd digits and the sum of even digits of the customer’s total bill amount. If no odd digit is present in the bill amount, then 0 will be consider for its corresponding sum.




Write an algorithm to find the discount amount for the given total bill amount.





1
Expert's answer
2022-01-26T17:49:12-0500
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>


/*
	An E-Commerce commerce company plans to give their customers a discount for the New Years holiday. 
	The discount will be calculated based on the bill amount of the order placed. 
	The discount amount is the product of the sum of all odd digits and the sum of even digits of the customer’s total bill amount. 
	If no odd digit is present in the bill amount, then 0 will be consider for its corresponding sum.
	Write an algorithm to find the discount amount for the given total bill amount.
*/


int main()
{
	int Bill,SumEven=0,SumOdd=0,n,r;
	printf("\mn\tEnter Bill Amount: "); scanf("%d",Bill);
	n = Bill;
	while(n!=0)
	{
		r = n%10;
		n = n/10;
		if(r%2==0) 	SumEven = SumEven + r;
		else		SumOdd = SumOdd + r;
	}
	printf("\n\tSum of Even Digits = %d",SumEven);
	printf("\n\tSum of Odd  Digits = %d",SumOdd);
	printf("\n\tFinal Discount = %d",SumEven*SumOdd);
	return(0);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS