1
I’m making a list of exercises and in one of them I need to calculate the inflation of two commodities from one month to the next. I was able to do the exercise for when inflation is <= 100%, but what if it’s bigger... any idea what I should do? Follows the code:
#include <stdio.h>
int main ()
{
float valorMarco1, valorMarco2, valorAbril1, valorAbril2, infl1, infl2, x1, x2;
printf("Insira o valor da mercadoria 1 em 01/março: ");
scanf("%f", &valorMarco1);
printf("Insira o valor da mercadoria 2 em 01/abril: ");
scanf("%f", &valorAbril1);
printf("Insira o valor da mercadoria 2 em 01/março: ");
scanf("%f", &valorMarco2);
printf("Insira o valor da mercadoria 2 em 01/abril: ");
scanf("%f", &valorAbril2);
x1 = (valorAbril1 * 100)/valorMarco1;
infl1 = x1 - 100;
x2 = (valorAbril2*100)/valorMarco2;
infl2 = x2 - 100;
printf("A inflação da mercadoria 1 teve o percentual de: %.1f \n", infl1);
printf("A inflação da mercadoria 2 teve o percentual de: %.1f", infl2);
}
Sorry anything, I’m a beginner.
In case it seems to be a math problem, not C. As already answered, I closed here for organizing purposes, but you can mark your own answer so the post is as solved.
– Bacco
All right. I can only schedule my answer for six hours. If I could change the category of my question I would change, but I don’t know if I have more editing options.
– Karina