LOOPING IN C

Can someone please tell me what is the best loop to use in the three types of looping:
[hr]
[b]for loop?
while loop?
or
do-while loop?[/b]
[hr]
any answers will be greatly appreciated...
[code][blue]============================[/blue]
[red]THANK YOU AND GODBLESS !!!
from playagain[/red]
[blue]============================[/blue][/code]

Comments

  • : Can someone please tell me what is the best loop to use in the three
    : types of looping:
    : [hr]
    : [b]for loop?
    : while loop?
    : or
    : do-while loop?[/b]
    : [hr]
    : any answers will be greatly appreciated...
    : [code]: [blue]============================[/blue]
    : [red]THANK YOU AND GODBLESS !!!
    : from playagain[/red]
    : [blue]============================[/blue][/code]:

    [blue]It depends on what is your task.

    1. When you need to use indesing in some array - for(;;){} loop is the one to use.

    2. If you need to perform some code before deciding to continue loop or not - do {} while (); is used.

    3. If you need to check some condition first and only then begin looping - then while(){} loop is used.
    [/blue]
  • : : Can someone please tell me what is the best loop to use in the three
    : : types of looping:
    : : [hr]
    : : [b]for loop?
    : : while loop?
    : : or
    : : do-while loop?[/b]
    : : [hr]
    : : any answers will be greatly appreciated...
    : : [code]: : [blue]============================[/blue]
    : : [red]THANK YOU AND GODBLESS !!!
    : : from playagain[/red]
    : : [blue]============================[/blue][/code]: :
    :
    : [blue]It depends on what is your task.
    :
    : 1. When you need to use indesing in some array - for(;;){} loop is
    : the one to use.
    :
    : 2. If you need to perform some code before deciding to continue loop
    : or not - do {} while (); is used.
    :
    : 3. If you need to check some condition first and only then begin
    : looping - then while(){} loop is used.
    : [/blue]


    If you're consern is efficiency, the do-while loop is the absolute fastest (any asm programmer whould know this).

    This is acctually one of the worst things that higher languages does (except for fpu and memmory addressing).
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories