user1564: Arduino Mega
I would like to have an array containing analog pin labels something like...
int analog_pins[] = {A0, A1, A2, A3};
int num_analog_pins = sizeof(analog_pins) / sizeof(analog_pins[0]);

Is this possible? It has compiled without any warnings or errors but I'm dont have my board with me (yes beginners mistake) so cant really check if it works.

user30198: As you can see in Arduino.h, the analogRead() has uint8_t as parameter. You can define them as byte or uint8_t and you don't have to use the sizeof().
The type of A0 is defined in the file pins_arduino.h:
#define PIN_A0 (14)
static const uint8_t A0 = PIN_A0;

Nevertheless, what you have with integers is 100% okay as well.
When you don't have a Arduino board available, you can use the simulation of an Arduino Uno at Tinkercad.

As @DataFiddler writes below this answer, using a 'const' keyword is preferred:
const uint8_t analog_pins[] = {A0, A1, A2, A3};


user34401: Your calculation will be correct for num_analog_pins, however it's convention to use the type of the array like so
int num_analog_pins = sizeof(analog_pins) / sizeof(int);

As @Jot noted, you'd save much space by declaring your array using uint8_t like so
uint8_t analog_pins[] = {A0, A1, A2, A3};
uint8_t num_analog_pins = sizeof(analog_pins) / sizeof(uint8_t);


1564: <p>Arduino Mega</p>

<p>I would like to have an array containing analog pin labels something like...</p>

<pre><code>int analog_pins[] = {A0, A1, A2, A3};
int num_analog_pins = sizeof(analog_pins) / sizeof(analog_pins[0]);
</code></pre>

<p>Is this possible? It has compiled without any warnings or errors but I'm dont have my board with me (yes beginners mistake) so cant really check if it works.</p>
 30198: <p>As you can see in <a href="https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/Arduino.h" rel="nofollow noreferrer">Arduino.h</a>, the analogRead() has <code>uint8_t</code> as parameter. You can define them as <code>byte</code> or <code>uint8_t</code> and you don't have to use the sizeof().</p>

<p>The type of A0 is defined in the file <a href="https://github.com/arduino/ArduinoCore-avr/blob/master/variants/standard/pins_arduino.h" rel="nofollow noreferrer">pins_arduino.h</a>:</p>

<pre><code>#define PIN_A0 (14)
static const uint8_t A0 = PIN_A0;
</code></pre>

<p>Nevertheless, what you have with integers is 100% okay as well.</p>

<p>When you don't have a Arduino board available, you can use the simulation of an Arduino Uno at <a href="https://www.tinkercad.com/" rel="nofollow noreferrer">Tinkercad</a>.</p>

<hr>

<p>As @DataFiddler writes below this answer, using a 'const' keyword is preferred:</p>

<pre><code>const uint8_t analog_pins[] = {A0, A1, A2, A3};
</code></pre>
 34401: <p>Your calculation will be correct for num_analog_pins, however it's convention to use the <em>type</em> of the array like so</p>

<pre><code>int num_analog_pins = sizeof(analog_pins) / sizeof(int);
</code></pre>

<p>As @Jot noted, you'd save much space by declaring your array using uint8_t like so</p>

<pre><code>uint8_t analog_pins[] = {A0, A1, A2, A3};
uint8_t num_analog_pins = sizeof(analog_pins) / sizeof(uint8_t);
</code></pre>
