Read the doc again - your are confused ... setup is running only once, before the first loop so what you are asking makes no sense. Whatever you initialise in the loop will happen after the setup, so would not have the intended result anyway.
Setup is for setting things up, so do X=5 in the setup and The setup does not loop, as its name implies, what loops is the
void loop() function
If you want to share variables between setup() and loop() then make them global (read about variables’ scope)
Thank you for the clarification. maybe i should provide some background on my current project which i hope can provide a better understanding.
im currently doing a project to control brushless DC motos using Arduino MEGA2560 and the PWM frequency determines the speed of the motors. with that, ive placed the following code into the setup function().
f1=8000; //inut freq of PWM
// setup for Timer4: change PWM frequency to 8000Hz for motor 1
TCCR4A = 0;
TCCR4B = 0;
TCNT4 = 0;
// Mode 10: phase correct PWM with ICR4 as Top (= F_CPU/2/8000)
// OC4C as Non-Inverted PWM output
ICR4 = (F_CPU/f1)/2; // F_CPU = 16Mega
OCR4C = ICR4/2; // default: about 50:50
TCCR4A = _BV(COM4C1) | _BV(WGM41);
TCCR4B = _BV(WGM43) | _BV(CS40);
the following code allows me to vary the speed of motor by manually changing the value of f1 only, but unable to use values calculated in void loop(). since im unable to vary the speed using values from main loop, i would like to seek alternatives in varying the speed of the motors which requires the change of PWM frequency.