Mega 2560 - error: 'led' was not declared in this scope

Just got the Mega 2560 as my first Arduino, and cannot get the first led project to work. Heres the code:

void setup() {
int led = 13;
pinMode(led,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led,LOW);
delay(1000);
}

Please take some time to read this:
https://www.arduino.cc/reference/en/language/variables/variable-scope--qualifiers/scope/

Because you declared the led variable inside of the setup function it is only in scope within that function. This is why you get the error that it was not declared in this scope when you try to use it in the loop function. In order to use the variable in both functions you need to declare it in the global scope like this:

int led = 13;

void setup() {
 pinMode(led,OUTPUT);
}

void loop() {
 // put your main code here, to run repeatedly:
 digitalWrite(led,HIGH);
 delay(1000);
 digitalWrite(led,LOW);
 delay(1000);
}

If you compare your code to File > Examples > 01.Basics > Blink you will see that's exactly what it does.