loops - Expected ')' before ';' token C -
i'm trying make program prints out ^2, ^4, , ^(1/3) of numbers between 0 , 100. have.
#include <stdio.h> #include <math.h> main(){ int a, b, c, i; (i=0; i<100; i=i+2;) = (1*1); b = (i*i*i*i); c = pow(i, (1/3)); printf("%d, %d, %d", a, b, c); return 0; }
it's giving me error on line 6 says
error: expected ')' before ';' token.
this first day c i'm stymied right now.
the following code shows suggested corrections posted code.
inserted comments explain changes
#include <stdio.h> // printf #include <math.h> // pow int main() // <-- use valid return type { int a; // value ^2 int b; // value ^4 double c; // value ^1/3 note: pow() returns double int i; // loop index // following loop calculates request values // 0 through 98. did want include '100'? (i=0; i<100; i+=2) // < corrected statement { // < added braces whole code block loops = (i*i); // < squared value, not 1 b = (i*i*i*i); c = pow( (double)i, (1.0/3.0) ); // < corrected integer divide printf("%d, %d, %lf \n", a, b, c); // printed double, // added newline // output displayed } // end return 0; } // end function: main
Comments
Post a Comment