Variable percentage in c [closed]

0

I have a problem with simple code, I want to know how to calculate the percentage of a value.

EX: 1500 + 15% (in this case I know it's value = value * 0.15)

But the percentage value must be a user-entered variable. So far I have the following code but I do not 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 ++
    }

}
    
asked by anonymous 25.03.2018 / 04:14

1 answer

-2

First you need the value in float, that is, divide the percentage value by 100. Beware of conversions (% w / w% would result in 0, as decimal places would be truncated when converting from float to int). With this, just do the multiplication.

    
25.03.2018 / 04:33