C PROGRAMMING HELP I need help with an old script of mine. I'm having trouble getting math involving accessing an array to work properly, I'm getting an error message that's puzzling me. I'm pretty sure the solution is simple and right in front of me but it's stumping me. Below is the script: #include #include void value(float x){ printf("what is the value of x?"); scanf("%f",&x); } void power(float i,int p,int x,float arr[100]){ float equation,butt; printf("what is the highest power in the series?"); scanf("%d",&p); for (i = 0; i < p; ++i) equation = pow(x,i); //how the hell do i get the counter to do what i want butt = 1+equation^arr[i]; } void shortcut(int x){ shortcut = 1/(1-x) } int main(){ printf("Here is the result!:") printf("%d %f", p, f); printf("If we had used shortcut, value would be: %d", shortcut); int diff; diff = shortcut - butt; printf("The difference is only %0.2f!",diff); getchar();return 0; }
C
I need help with an old script of mine.
I'm having trouble getting math involving accessing an array to work properly, I'm getting an error message that's puzzling me. I'm pretty sure the solution is simple and right in front of me but it's stumping me.
Below is the script:
#include <stdio.h>
#include <math.h>
void value(float x){
printf("what is the value of x?");
scanf("%f",&x);
}
void power(float i,int p,int x,float arr[100]){
float equation,butt;
printf("what is the highest power in the series?");
scanf("%d",&p);
for (i = 0; i < p; ++i)
equation = pow(x,i);
//how the hell do i get the counter to do what i want
butt = 1+equation^arr[i];
}
void shortcut(int x){
shortcut = 1/(1-x)
}
int main(){
printf("Here is the result!:")
printf("%d %f", p, f);
printf("If we had used shortcut, value would be: %d", shortcut);
int diff;
diff = shortcut - butt;
printf("The difference is only %0.2f!",diff);
getchar();return 0;
}
Thank you for your help!
Step by step
Solved in 3 steps with 2 images