All the pins are configured as INPUT by default on startup. So if you leave out the pinMode(7, OUTPUT);
, pin 7 will still be configured as input. An Input doesn't provide any current (or only a very very low leak current), so the LED will be off in this time.
When you write HIGH to a pin, while it is configured as INPUT, you are activating the internal pullup resistor. This is a resistor (typically about 10kOhm) from the pin to Vcc (HIGH level) inside the microcontroller itself. Now a small current - set by the total resistance (your resistor + internal pullup) - can flow through the diode, making it light up very dim.
Configuring a pin as INPUT with the internal pullup resistor activated can be done in one command: pinMode(7, INPUT_PULLUP);
, which makes the intent more clear, but does exactly the same under the hood as setting to INPUT and writing HIGH to the pin.
pinMode(7, INPUT);
andpinMode(7, INPUT_PULLUP);