Math in arduino

what I have so far...

I am reading a voltage in analogRead on pin 0. I am serialWrite that value.
what I want is to use math in arduino to create a new variable that holds the value of the voltage that I am reading divided by 5 and then output to serial. can anyone please help me with this. Sorry if I am a noob and such

what I want is to use math in arduino to create a new variable that holds the value of the voltage that I am reading divided by 5 and then output to serial.

Are you asking for permission? If so, it's granted.

If not, then surely you know how to define a variable. After all, you had to do that to hold the value read from the pin. So, create another one. Dividing by 5 is a no-brainer.

const uint8_t   pinAnalog   = A0;

int     analog;
int     analogModifiedAsInteger;
float   analogModifiedAsFloat;

void setup()
{
    Serial.begin(9600); 
}

void loop()
{
    analog = analogRead(pinAnalog);             // 0 - 1023, a counting (aka integer) number
    
    Serial.print("sensor = " );
    Serial.println(analog);

    analogModifiedAsInteger = analog / 5;       // 0 -  204

    Serial.print("\t output = ");
    Serial.println(analogModifiedAsInteger);


    analogModifiedAsFloat   = analog / 5.0f;    // 0.0 -  204.6

    Serial.print("\t output = ");
    Serial.println(analogModifiedAsFloat);
    
    delay(10);                     
}

Moderator edit: Code tags added.

thank you guys im actually done. it was a no brainer. I was doing it just after I asked the question. Thanks for the permission though

ortonjon:
thank you guys im actually done. it was a no brainer. I was doing it just after I asked the question. Thanks for the permission though

Hopefully this means the next time you run into an issue, your first thought is "I'm a smart guy, I can figure this out!" rather than "I bet someone else knows how to do it."