7-6 Calculate deposit interest (10 points)

This topic requires the calculation of deposit interest. The calculation formula is interest=money×(1+rate)
​year
​​ −money, where interest is the interest at the expiration of the deposit (before tax), money is the deposit amount, and year is the deposit period. rate is the annual interest rate.

Input format:
Input three positive real numbers money, year and rate in one line, separated by spaces.

Output format: output in the format of
"interest = interest" in one line, with two decimal places for interest.

Input sample:

1000 3 0.025

Sample output:

interest = 76.89
#include <stdio.h>
int main (void)
{
    
    
	int money;
	double interest, rate, year;
	scanf("%d %lf %lf", &money, &year, &rate);
	interest=0;
	interest=money*pow((1+rate), year)-money;
	printf("interest = %.2lf", interest);
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_45814538/article/details/108885872