compound addition to 7 segment

I am very new to using microcontrollers so please excuse any major flaws with the following piece of code. i want 3 analog inputs to add (+=) and the cumulative total (x) to be displayed on a seven segment display. below is where i am so far. i have no idea if this is even close to correct so any assistance would be great.

void loop ()
if (analogRead(1) < 20 x += 1; // if only the low sensor is activated +1 is added to var
if (analogRead(2) < 20 x += 2; // middle sensor +2
if (analogRead(3) < 20 x += 3; // top sensor +3
{ (x) == 1
digitalWrite(2, 0);
digitalWrite(3, 1);
digitalWrite(4, 1);
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(7, 0);
digitalWrite(8, 0);}// write '1'
{int (x) == 2
digitalWrite(2, 1);
digitalWrite(3, 1);
digitalWrite(4, 0);
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(7, 0);
digitalWrite(8, 1)};// write '2'
{int (x) == 3
digitalWrite(2, 1);
digitalWrite(3, 1);
digitalWrite(4, 1);
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(7, 0);
digitalWrite(8, 1)};// write '3'
{int (x) == 4
digitalWrite(2, 0);
digitalWrite(3, 1);
digitalWrite(4, 1);
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(7, 1);
digitalWrite(8, 1)};// write '4'
{int (x) == 4
digitalWrite(2, 1);
digitalWrite(3, 0);
digitalWrite(4, 1);
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(7, 1);
digitalWrite(8, 1)};// write '5'

Have you actually tried compiling that yet and testing the results? I expect you'll see a few errors once you do.

Is this a college project? You're not the only one asking this question.

I suggest you tackle the problem in steps.

Write a sketch that reads an analog input and prints the value to the Serial port so you can read it on the PC.
Then compare the value against a threshold and decide whether you consider the value 'high' or 'low'.
Then do this for three inputs and print out the number that are 'high'.
Then write a different sketch that displays the digits 0 .. 3 on your display.
Then combine that code into your original sketch to display the number of 'high' inputs each time the number changes.

you nailed it. elec. engineering major at NCSU. if you don't mind send me the links to any other forum topics simular to my project (i need all the help i can get) but in regards to the serial output to the pc how would that sketch look? Serial.print.....? also when you say is the value HIGH or LOW do you mean <20 = low >20 = high?
thanks for the help

Try looking at the example sketches in the IDE. They cover most of what you want. AnalogInOutSerial will get you started. Make use of Arduino - Home. Look at Seven Segment Displays on Arduino Playground - InterfacingWithHardware too.