Answer to Question #235028 in C for New

Question #235028
Question 1

While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 10. If quantity and price per item are input through the keyboard, write a program to calculate the total expenses.
1
Expert's answer
2021-09-09T04:09:59-0400
#include<stdio.h>
int main(){
	int quantity;
	float price;
	float totalExpenses;
	printf("Enter the quantity purchased\n");
	scanf("%d",&quantity);
	printf("Enter the price per item \n");
	scanf("%f",&price);
	if(quantity>10){
		totalExpenses = quantity * price; 
		totalExpenses = totalExpenses - (totalExpenses * 0.1);
	}
	else{
		totalExpenses = quantity * price; 
	}
	
	printf("Total Expenses is: %f",totalExpenses);
}

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