9 views (last 30 days)

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:

- The program must ask the user to input the temperature in Fahrenheit.
- The program must display the temperature in Celsius.

Walter Roberson
on 19 Sep 2020

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

stozaki
on 19 Sep 2020

Edited: stozaki
on 19 Sep 2020

Hello

Here is an example of calculation

% Define the value of F used in the calculation as a "vector".

F = [70 80 75 84 92];

% Calculate the average value of F using the mean function.

AveC = mean(5/9*(F - 32))

AveC =

26.7778

documentation for mean function

stozaki

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 7 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015420

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015420

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015459

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015459

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015735

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015735

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015828

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015828

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015861

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1015861

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1021501

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1021501

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1022497

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/596407-how-to-use-while-true-loop-for-this-qustion#comment_1022497

Sign in to comment.