Hmm...
can we use the continue statement in if-else statement?
as i know the continue statement only can use under for loop right?

and also is there any idea how to write pseudocode of for loop ?
give some sample examples.
thanks alot. :)

continue statement is designed for loops (for or while, or do while). Wouldn't make sense to try and use it in an if/else statement.

You can have a "do nothing" in an if statement, however:

if(numberOfApples > 1)
  ;               //nothing gets done
else
  printf("\nNo apples here yet!");

Good pseudo code is just structured English or language:

for each apple in the bowl {
  if the apple is ripe
    remove the core
    remove the skin
    slice it into 8th's
    roll it in cinnamon and sugar
    put it into the pie
  else
    if the apple is green    
      return it to the bowl
    else
      throw it out
}

Mine is generally a toss up between BASIC, C and Python. The key thing is that the logic has to be understandable. I'm no pseudocode guru, however. ;) I'm sure your teacher will have a preferred way that he/she wants it done. THAT's the way to do it, as least for now. :D

Edited 6 Years Ago by Adak: n/a

>>can we use the continue statement in if-else statement?
No

>>i know the continue statement only can use under for loop right?
No. Can also be used on do and while loops.

pseudocode

set loop counter to 0
beginning of loop
   increment (or decrement) loop counter
   if loop counter matches some condition
      exit the loop
   do something here
end of loop

continue statement is designed for loops (for or while, or do while). Wouldn't make sense to try and use it in an if/else statement.

You can have a "do nothing" in an if statement, however:

if(numberOfApples > 1)
  ;               //nothing gets done
else
  printf("\nNo apples here yet!");

Good pseudo code is just structured English or language:

for each apple in the bowl {
  if the apple is ripe
    remove the core
    remove the skin
    slice it into 8th's
    roll it in cinnamon and sugar
    put it into the pie
  else
    if the apple is green    
      return it to the bowl
    else
      throw it out
}

Mine is generally a toss up between BASIC, C and Python. The key thing is that the logic has to be understandable. I'm no pseudocode guru, however. ;) I'm sure your teacher will have a preferred way that he/she wants it done. THAT's the way to do it, as least for now. :D

oh i see,
thanks for the telling me. :)
about the pseudocode right,
i think we dont need to write the symbol of '{' and '}'.
but anyway, thanks for the helping :)

>>can we use the continue statement in if-else statement?
No

>>i know the continue statement only can use under for loop right?
No. Can also be used on do and while loops.

pseudocode

set loop counter to 0
beginning of loop
   increment (or decrement) loop counter
   if loop counter matches some condition
      exit the loop
   do something here
end of loop

the 'beginning of loop' is it write the condition ?
if it is write condition, which mean write like while loop pseudocode, but have to add increment or decrement the counter only. am i right?

Hmm...
can we use the continue statement in if-else statement?
as i know the continue statement only can use under for loop right?

and also is there any idea how to write pseudocode of for loop ?
give some sample examples.
thanks alot. :)

No you can not use continue statement in if-else.It only works for the loops.
if you want to do something in the if-else statement then you can use goto instead of continue but remember that goto is DANGEROUS.

This is somewhat unclear, as it does not make sense at some point.

Using continue; in a plain if/else statement returns an error when compiling. On the other hand, you said "[...] can we use it in a if/else statement?", but you only use it in a if/else inside a loop, either a for or a while loop. So... the answer is somewhere in between.

No you can not use continue statement with if else statement. continue keyword is use for direct jump on loop entry point. if you require jump on if entry point use can place label and use goto statement in the scope of if_else statement.

This question has already been answered. Start a new discussion instead.