compilation - c++ statement has no effect -


i'm having problems homework , can't find answer.

i have simple program solves math problem, not comp

this code:

#include <iostream> #include <math.h>  using namespace std;  int main () {     int a, b, firsta;     int result = 0;     firsta = a;      // sum of cubes between , b: (a^3 + (a + 1)^3 + .. + (b + 1)^3 + b^3)     while (cin >> >> b) {         (a; <= b; a++) {             result = result + pow(a,3);         }         cout << "suma dels cubs entre " << firsta << " " << b << ": " << result << endl;     }  } 

the error gives this:

program.cc: in function ‘int main()’: program.cc:23:15: error: statement has no effect [-werror=unused-value]      (a; <= b; a++) { 

all warnings being treated errors.

what should do?

you have unused value in for (a; <= b; a++) because a; makes no sense.

use for-loop without initialization: for (; <= b; a++).


Comments