Question
Asked by:
cowboy
cowboy
Rating : No Rating
Questions Asked: 19
Tutorials Posted: 0
 

$1.00 IT Question

Q:
Explain when you would use a while loop rather than a for loop and vice versa. Provide an example of one such instance. How are looping statements different from selection statements?
 


   
   
   
   
 
Available Tutorials to this Question
Posted by:
itutor
itutor
Rating (6): A+
Questions Asked: 1
Tutorials Posted: 42, earned $168.99
 

$5.00 difference between while loop and for loop

  • This tutorial was purchased 4 times and hasn't been rated yet.
  • Posted on Dec. 03, 2007 at 08:44:52AM
A:
Preview: ... AMONG OTHER THINGS).<br><br>you can specify the condi ...

The full tutorial is about 43 words long .
Posted by:
techy
techy
Rating (205): B+
Questions Asked: 2
Tutorials Posted: 637, earned $13,300.98
 

$0.25 differences are explained clearly in the solution

  • This tutorial was purchased 40 times and rated A+ by students like you.
  • Posted on Dec. 03, 2007 at 08:48:59AM
A:
Preview: ... until the variable x has the value 3.<br><br>Note that it is possible, and in some cases desirable, for the condition to always evaluate to true, creating an infinite loop. When such a loop is created intentionally, there is usually another control structure (such as a break statement) that controls termination of the loop.<br><br>In computer science a for loop is a programming language statement which allows code to be repeated ...

The full tutorial is about 357 words long .
Posted by:
b_h
b_h
Rating (671): A+
Questions Asked: 0
Tutorials Posted: 1188, earned $24,641.40
 

$0.25 For vs. While

  • This tutorial was purchased 17 times and rated A+ by students like you.
  • Posted on Dec. 03, 2007 at 11:38:42AM
A:
Preview: ... while loop.<br><br>If we have:<br><pre><br>for( i = 0; i <= a; i++) {<br> // do something<br>}<br></pre><br>Then that's the same as the while loop:<br><pre><br>i = 0;<br>while(i <= a) {<br> // do something<br> i++<br>}<br></pre><br><br>But wait! We can write a while loop as a for loop! If we have the while loop:<br><pre><br>while(condition == true) {<br> //do something<br>}<br></pre><br>Then we can write it as the equivalent for loop:<br><pre><br>for (;condition == t ...

The full tutorial is about 394 words long .
Posted by:
prospectiveman
prospectiveman
Rating (1507): B+
Questions Asked: 0
Tutorials Posted: 10941, earned $56,121.39
 

$2.00 clear explanations and typical examples

  • This tutorial was purchased 2 times and hasn't been rated yet.
  • Posted on Mar 17, 2009 at 2:17:03PM
A:
Preview: ... s and t ...

The full tutorial is about 5 words long plus attachments.

Attachments:
Explain when you would use a while loop rather than a for loop and vice versa.doc (24K) (Preview)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty