2017-02-07 11 views
-2

Error: invalid operands of types 'float' and 'float' to binary 'operator^'エラー: 'float'型と 'float'型の無効なオペランドがバイナリ 'operator ^'

このエラーが発生している理由を教えてもらえますか?

#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); 
    } 
} 
+0

あなたのコードに '1.2^2.0'のようなものがありますか? – user463035818

+1

コードを表示してください – atb

+1

あなたは['pow'](http://ja.cppreference.com/w/cpp/numeric/math/pow)をお探しですか? –

答えて

4

XOR演算子^の引数は、C++では整数型でなければなりません。

std::powは、C++の指数に使用されています。

関連する問題