C. It cannot be used directly in C + +^
In C and C + +, you can’t use ^ to represent the index, only * can be used. If you want to use the index, you can only establish a cycle to multiply multiple times or write multiple directly by multiplication. The following is my code. The comment part is the original index form, and the above error will be reported.
Or reference mathematical functions and add #include & lt; math.h>;
Pow (x, y) is used to solve the Y power of X;
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
double p0=1000,r1=0.0036,r2=0.0225,r3=0.0198,p1,p2,p3;
p1=p0*(1+r1)*(1+r1)*(1+r1)*(1+r1)*(1+r1)*(1+r1);
//p1=p0*(1+r1)^6;
p2=p0*(1+r2)*(1+r2)*(1+r2);
//p2=p0*(1+r2)^3;
p3=p0*(1+r3)*(1+r3);
//p3=p0*(1+r3)^2;
double x=1,y=2,p;
p = pow(x+1,y); //Find the yth power of x+1, which is the exponent
printf("The square of 1+1 is %lf",p);
printf("deposit 1 year %lf, deposit 2 years %lf, deposit 3 years %lf",p1,p2,p3);
return 0;
}
Read More:
- [Solved] error: invalid operands of types ‘const char [6]‘ and ‘const char [6]‘ to binary ‘operator+‘
- Error: (list) object cannot be coerced to type ‘double’
- [Solved] JSON parse error: Unexpected character (‘‘‘ (code 39)): was expecting double-quote to star
- [Solved] JSON parse error: Unexpected character (‘‘‘ (code 39)): was expecting double-quote to start ……
- Redis cannot double-click redis-server.exe to start normally
- Numpy.exp Function Error ‘Float’ object has no attribute ‘exp’
- [Solved] Runtimeerror during dcgan training: found dtype long but expected float
- [Solved] Matlab Code generate error: failed to generate all binary outputs
- ValueError: Input 0 of node import/save/Assign was passed float from import/beta1_power:0 incompatib
- [Solved] GLSL Lint: Failed to spawn ‘glslangValidator‘ binary. Error: spawn glslangValidator.exe ENOENT
- [Solved] Message from debugger: debug-server is x86_64 binary running in translation, attached failed.
- [Solved] Appium Error: InvalidArgumentException: Message: invalid argument: invalid locator
- [Solved] SyntaxError: Invalid regular expression: invalid group specifier name
- target is multiclass but average=’binary’. please choose another average setting.
- [Solved] iperf Analyze Error: unable to create a new stream: Invalid argument
- C++ Compile Error: error: invalid conversion from ‘void*‘ to ‘char*‘ [-fpermissive]
- [Solved] Opencv Call yolov3 Error: IndexError: invalid index to scalar variable
- AUC Error – ValueError: Data is not binary and pos_label is not specified
- [Solved] Android Studio Error: The binary version of its metadata is 1.5.1, expected version is 1.1.15.
- [Solved] Use the truss console to connect to the public blockchain network error: mnemonic invalid or undefined