错误:类型的无效操作数' float'并且'漂浮'到二元'运算符^'

时间:2017-02-07 14:53:05

标签: c++

  

错误:类型无效的操作数'浮动'并且'漂浮'到二元'运算符^'

有人可以告诉我为什么我会收到此错误吗?

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

int main()
{
  int a,w;
  float P,M,y,i,n;
  for(a=1;a=2;)
  {
    printf("Enter the value of Pricipal \n");
    scanf("%f",&P);
    printf("Enter the value of yearly interest rate \n");
    scanf("%f",&y);
    i=y/12;
    printf("Enter Term in years \n");
    scanf("%d",&w);
    n=w*12;
    M=(P*i*((1+i)^n))/(((1+i)^n)-1);
    printf("Monthly Payment is %f \n",M);
  } 
}

1 个答案:

答案 0 :(得分:4)

XOR运算符^的参数必须是C ++中的整数类型。

请注意,std::pow用于C ++中的指数化。