How to use a variable from a different scope

Hi. How can I use a variable from a different scope?
What I am trying to do is initialize my temperature to current temperature at start up in the void setup loop. I only want to run this initialization process once and then use that data as an intitial comparison variable in a logical test in the void loop section to determine and update other variables such as lowest recorded temperature and highest recorded temperature.

How can I use a variable from a different scope?

Simple answer, make it global.

Yes, but I have to first determine the initial temperature by reading it from my sensor, which means I have to run some code in either the setup or loop functions first?

Yes, that's correct.

Ok, so how do I make the variable in my setup loop a global, so that I can use it in my void loop ?

Ok, so how do I make the variable in my setup loop a global, so that I can use it in my void loop ?

What "setup loop"?
I can't see a loop in your setup. (hint)

A variable declared inside the function "setup" cannot be accessed outside of "setup", just as a variable declared inside the function "loop" cannot be accessed outside of "loop".

int x=0;  //<--global variable

void setup(){
  int y=0;  //<--variable only accessible in setup()
  x=1;       //<--assign value to z
}

void loop(){
  int z=0;  //<--variable only accessible in loop()
  Serial.println(x);  //<--prints: 1
  Serial.println(y);  //<--Compiler error!!!!!!!!! (y is undefined in the scope of loop)
}

'x' is global so you can access it anywhere in the file, you can't access 'y' cos its local to setup()
What is the problem? You can just make 'y' global if you really need it 'global'.

Ok, so what I'm trying to do is get an initial temperature reading from my sensor. Lets call it
initialTemperature. I only need to get this temperature once so that is why I want to code it in my void setup part of my program. So every time at arduino starts up or is reset it gets an initial temperature reading called initialTemperature. I then want to use this constant whatever it may be (18, 20 or whatever temperature) in my loop part of my program to to constantly determine and update two other variables called lowestRecordedTemperature and highestRecordedTemperature. For example;
if (temperature > initialTemperature) {
lowestRecordedTemperature = temperature
} else if
(temperature < initialTemperature) {
highestRecordedTemperature = temperature
}

My problem is I don't want to keep running initialTemperature in the void loop, I only need to determine that value once in the setup. But the setup and void loop are two different scopes.

I still don't see the problem. Make initialTemperature global, read it in setup() then use the value in loop(). Job done.