Search code examples
cmathexpressionlvalue

Expected expression before equation in C


I'm making a little C program that works out the area and circumference of circles, and I want this equation to be worked out, but each time it says "lvalue required as left operand of assignment" for the top line, and "expected expression before "=" token" for the second line I've tried everything i can think of, but nothing seems to be working. I've read other articles on things like this, but I couldn't work it out.

(float)circ_area = (CircleRadi * CircleRadi) * 3.1415926538;
(float)circ_circum; = (CircleRadi * 2 )* 3.1415926538;

This is just during the middle of the code, not within any loops or anything. I can post the whole code if you want.


Solution

  • Replace your 2 lines with:

    circ_area = (CircleRadi * CircleRadi) * 3.1415926538;
    circ_circum = (CircleRadi * 2 )* 3.1415926538;
    

    I'm supposing that circ_area and circ_circum are both floats and have been declared previously.