Why is my power operator (^) not working?

前端 未结 8 1430
半阙折子戏
半阙折子戏 2020-11-22 02:12
#include 

void main(void)
{
    int a;
    int result;
    int sum = 0;
    printf(\"Enter a number: \");
    scanf(\"%d\", &a);
    for( int i =         


        
8条回答
  •  没有蜡笔的小新
    2020-11-22 03:01

    Instead of using ^, use 'pow' function which is a predefined function which performs the Power operation and it can be used by including math.h header file.

    ^ This symbol performs BIT-WISE XOR operation in C, C++.

    Replace a^i with pow(a,i).

提交回复
热议问题