Explain the goto statement, C/C++ Programming

Assignment Help:

The goto statement

This statement can be used to branch to another statement of the program. This is rarely used as it violates the principle of structured programming. Though we can use it when we require to exit from deeply nested loops. The general format is :

goto label;

where label is a name(tag) followed by a colon.

e.g.

                for( . . . )

                 {

                                for( . . . )

                                {

                for( . . . )

                 {

                for( . . . )

 {

                if( condition)

                                goto cleanup;

 }

                                                 }

                                 }

                 }

 

cleanup: statements;

                                :

                                :

A good programmer will use control statements effectively in order to avoid the usage of unconditional branching statement - goto.

 


Related Discussions:- Explain the goto statement

I want to convert atmel c code into arduino mppt, Normal 0 fals...

Normal 0 false false false EN-US X-NONE X-NONE

Decodethecode, 6999066263304447777077766622337778 -----> message sent by th...

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space".

Function, write a function named "fact"that takes one integer arguments,ca...

write a function named "fact"that takes one integer arguments,call them "num" and returns as ..............

How many ways are there to initialize an int with a constant, There are two...

There are two ways for initializes in C++ as shown in the example that follows. The first way uses the traditional C notation. The second way uses constructor notation. int foo

Bankers algorithm, creating a system having five process from p0 to p4 and ...

creating a system having five process from p0 to p4 and five resource types. create the need matrix use the safe algorithm to test if the system is in safe mode.

Area, write a program to find the area under the curve y=f(x) between x=a &...

write a program to find the area under the curve y=f(x) between x=a & x=b

Minimumshelf, At a shop of marbles, packs of marbles are prepared. Packets ...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd