Posted By:
2 Jul, 2013 6:43 am PDT

goto statement in C++

What is goto statement? What is the use of it?

goto allows absolute jump to another point in the program. The use of goto should be limited because the execution of goto can cause unconditional jump ignoring any type of nesting limitations.

The destination point is identified by a label which is then used as an argument for goto statement.


// Program to print from 5 down to 1 using goto



int main()


int n;



cout<<n<<"  ";



goto loop;

cout<<"\nEnd of goto";




Output of the program is:

5  4  3  2  1

End of goto


In line 10 the goto keyword is encountered, so the execution of the program now continues from line 6.


Was it useful?  

Please login to reply to this problem.