Thursday
April 24, 2014

Homework Help: Computer Science (MATLAB)

Posted by Jhon on Tuesday, November 1, 2011 at 3:02pm.

I had a test in my computer science course in which I was asked if any while loop can be replaced with a for loop. I put true. I guess the answer was false. My professor said that if you had a while loop in which you asked the user to input a certain value that had to be within a certain range and kept on iterating over the loop until the user inputted a value within the range that you wouldn't be able to do this with a for loop.

I however thought that any for loop can be written with a while loop and any while loop can be rewritten with a for loop. I think I may have even read something about this in my textbook but am unable to come up away with doing what my professor said with a for loop but believe that it's possible. Can anyone please come up with a way to do such a thing with a for loop?

for example a while loop

A=0;
while A<1
x=input('Enter a value');
if x>4 && x<10
A=1
else
end

this would force the user to enter a number between 4 and 10, not including 4 and 10, and would just keep on iterating over the loop until the user does.

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

English - 1. He had the man fix the computer. 2. He had the computer fixed by ...
probability - out of 250 students interviewed at a community college, 90 were ...
English - Let's write down what you can do with the computer. 1. I use the ...
Probablity - Samir had prepared the problem tests for Stages 1 to 5 of Geometry ...
computer - What does tenure track, part time instructor of computer science does...
Computer Science (MATLAB) - I had a test in my computer science course in which ...
computer - what are the safety rules in handling a computer unit? Read the ...
computer - how do you install the SRI test to your computer?
English - 1. After each meal, I drew a chart with /on a computer that I had ...
math - by selling 90 computer a shopkeeper gains the amount which is equal to ...

Search
Members