Write a program that calculates the inclusive price (double type) of an item from the net price (type int) and the VAT percentage (type int) to be added. Use the following formula, paying attention to priorities and automatic type conversions: $$PTTC = PNET + PNET * \frac{TVA}{100}$$
Write a program that calculates the net price of an item (double type) from the inclusive price (double type) and the VAT percentage (type int) that has been added.
(Deduct the formula from the calculation given above)
Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
int main()
{
int PNET, TVA ;
double PTTC;
printf("Enter the net price and the VAT: ");
scanf("%d %d", &PNET, &TVA);
PTTC = PNET + PNET * TVA/100.0 ;
printf("Total price = %.2lf\n",PTTC);
return 0;
}
#include <stdio.h>
int main()
{
int TVA ;
double PNET, PTTC;
printf("Enter the total price and the VAT: ");
scanf("%lf %d", &PTTC, &TVA);
PNET = PTTC * 100 / (100 + TVA);
printf("Net price = %.2lf\n",PNET);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Checking whether a given binary tree is a BST