I am getting an expression result unused error when working on the credit program. My code is as follows:

for (i = 1, i <= length, i = i+2)
    a = num / (pow (10,(i-1))) - 10 * num / (pow(10,i)) ;
    printf ("%i\n",a) ;

length is calculated as an integer earlier in the program. Can anyone tell me what's wrong here?

  • the code you post is insufficient to respond, may initialize a variable that you do not use throughout the program, or you use a function that should return a value but it does not
    – MARS
    Jun 19 '16 at 20:36

Punctuation. Review this line for (i = 1, i <= length, i = i+2). Are you also getting this error: error: expected ';' in 'for' statement specifier ? That is not correct for syntax.

  • Thanks, I realized this after watching week 2 this morning, sometimes you can't see what's staring you in the face! Was using commas not semi colons. Jun 20 '16 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .