RETURN(0) OR JUST RETURN;

 

Hi Everyone!

Hope all's well with all! Which is the appropriate return statement to use(return(0) or just return;,,,,,and is there a difference) just to exit the "if" loop without exiting the entire program? All feedback highly appreciated. Thanks yo'all.

 
Kenneth Njuguna:

Hi Everyone!

Hope all's well with all! Which is the appropriate return statement to use(return(0) or just return;,,,,,and is there a difference) just to exit the "if" loop without exiting the entire program? All feedback highly appreciated. Thanks yo'all.


Hi, 


There is no such think as an "if loop". To exit a loop you use the ketword 'break'.

while(true)
{
   break;
}
 
nicholishen:

Hi, 


There is no such think as an "if loop". To exit a loop you use the ketword 'break'.


Hi, there is such a thing as a "if" loop. I have used it within my code severally. Anyway, will try to use the "while" loop with "break" as exit mechanism and see how that works out. Thanks nicholishen.

 
Kenneth Njuguna: Hi, there is such a thing as a "if" loop. I have used it within my code severally. Anyway, will try to use the "while" loop with "break" as exit mechanism and see how that works out. Thanks nicholishen.

It is NOT an "if" loop. No such thing exists. it is an "if" operator. It does not loop. It only executes one block or another of code.

Reason: