0
I have a problem with a simple code, I want to know how to calculate the percentage of a value.
EX: 1500 + 15% (in this case I know it is value = value*0.15)
However, the percentage value must be a variable informed by the user. So far I have the following code but I don’t think it will help.
#include <stdio.h>
//Escreva um programa que leia: o valor de uma aplicação, o
//percentual de rendimento mensal obtido por esta aplicação e o
//período do investimento; e retorne o valor da aplicação ao final do
//período de investimento.
int main (){
float aplicacao = 0;
float rendimento = 0;
float ff = 0;
int periodo = 0;
int cont = 0;
while (cont < periodo){
ff = aplicacao + rendimento
cont ++
}
}
Wouldn’t that be 15/100 ?
– Sveen
@Sveen did you mean
15.0/100
, Isn’t that right? In C, if you have no reason to split floating points, this division will not be made. This is why it is important to ensure that the numerator or denominator is a floating point number– Jefferson Quesado
How will this percentage be informed? It will be typed
15
to represent15%
? Or will be typed15.0
? Or even0.15
? And accepts less than1%
? For example, it makes sense for the user to enter some value that represents15.3%
?– Jefferson Quesado