MATLAB: How to use while true loop for this qustion

loopwhilewhile loop

The Fahrenheit temperature is converted to Celsius temperature by the following formula , write a script file to accept temperature in Fahrenheit and calculate its Celsius equivalent for 5 times using DO WHILE loop.
While writing the Program please consider the Following:
  1. The program must ask the user to input the temperature in Fahrenheit.
  2. The program must display the temperature in Celsius.

Best Answer

assign initial conditions
while true
do a calculation
if condition is satisfied
break;
end
end
here, "condition is satisfied" needs to be expressed the opposite way than you would use for a "do while". For example in C
do {
x = rand();
} while x > 0.1;
would become
while true
x = rand() ;
if x <= 0.1; break; end
end
Notice the C condition of x > 0.1 becomes the condition x <= 0.1