what is the code which does the following?

Came across a programming question that i got stuck in. Help pls

Write a code to:

read the value(name the value "flexValue") of a "flex Sensor" that is connected to analog input AN0 of the Arduino. The value will be a 10-bit integer number having a value between 0 and 1023 inclusive.

Thanks a bunch! :-)

https://www.arduino.cc/en/Reference/AnalogRead

//Flex Sensor Pin (flexPin) //the analog pin the Flex Sensor is connected to AN0

int flexPin = 0;

// read value of flex sensor flexValue=analogRead(flexPin);

This was the code i got..

however, it says 'error: 'flexValue' does not name a type'..

That's the part im confused about. What's wrong with this code?

You didn't declare the type for flexValue.

so i read up online and it says to 'declare a variable type', you need to write 'int' before the variable, which i did. so now ive got:

//Flex Sensor Pin (flexPin) //the analog pin the Flex Sensor is connected to AN0

int flexPin = 0;

// read value of flex sensor int flexValue=analogRead(flexPin);

but im still getting an error, saying :

undefined reference to setup undefined reference to loop

How do i fix this?

By adding setup() and loop() functions. This is fun.

You can go the the File tab in the IDE and select "New". :)