使用幂函数时float = int

Muk*_*215 0 c floating-point

我试图运行这个,似乎无法找出它为什么不会运行.先感谢您.请知道我是新人.

#include <stdio.h>
#include <math.h>

int main(void)
{
float IR;
float invested;
float time;

printf("Please enter the following to be calculated:");
scanf("Interest rate: %f\n", &IR);
scanf("Amount invested: %f\n", &invested);
scanf("Time: %f\n", &time);

float ans;
ans = (invested(((float)1+((IR)^(time)))));

printf("%f", ans);
}
Run Code Online (Sandbox Code Playgroud)

Dan*_*iel 6

^不是力量的功能.你需要使用ans = invested * (1 + pow(IR, time));

^是按位异或XOR.