Lets continue with the statements ….
Continue statement leads to the end of the current iteration and leads to the new iteration . It allows the complier to reach the end of the block of statemnts of the loop , i.e skipping all the statemnts in the loop , hence end the current iteration and leads to start the new iteration .
here in this example again we have used for loop and output without a continue should have been
but if ull notice it carefully “3” is missing , it is because in continue the control goes to the starting of the loop .Similar happened in our case as soon as it encountered a continue it didnt executed the next statement rather it went to the start of the loop to continue its execution .
Goto allows you to jump from one part of the code to another . All this is done via labels . Since it makes unconditional jumps so utmost care should be taken try to use this in local block.
Label can be defined as
i.e it can be anything word letter and you can even use numbers eq L1 but it should always end with a colon (:) .
consider the following example
here in this example goto statement is used .Here if goto statement was absent then the output would have been ..
but goto statement is used here hence when the loop counter goes to 3 then due to if statment in the loop the goto statemnt is executed and it searches for its label that is in our case l1. Now when the label is found then the flow of control of the program shifts to the statement ” cout<<“enter a number”; ” and it continues the execution of program from that statemnt until a condition is reached where the goto statment is not used . and then it comes out of the loop
The rest of the topic is discussed in the next post.