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

Explain the polymorphism in object-oriented programming, Problem: (a) ...

Problem: (a) A GUI can contain text-fields, buttons, and other labels. A button usually triggers an event on the GUI. Explain the different processes in registering an event

What''s the deal along with operator overloading?, A: It let you to provide...

A: It let you to provide an intuitive interface to users of your class, as well as makes it possible for templates to equally work well with classes and built-in/intrinsic types.

Explain public derivation, Public derivation Public derivations are muc...

Public derivation Public derivations are much more common than private derivations. In this situation: The private members inherited from the base class are inaccessible

Program to make another type of mask, Write a function that has int paramet...

Write a function that has int parameter n, makes another type of mask having n bit 1's from the left most bit and 32- n bit 0's next. The mask is called netmask in this seminar, an

Padovan string., #question.A Padovan string P(n) for a natural number n is ...

#question.A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a s

Data Handling in computers, though the ascii is called 7-bit code. why do w...

though the ascii is called 7-bit code. why do we use 8-bits to represent a character?

Friends of classes, Define the following Window class : - integer  data mem...

Define the following Window class : - integer  data members, width and height - a constructor  that accepts two integer  parameters  (width followed by height) and uses them to ini

Implementation of the definition class - c++ program, Implementation of the...

Implementation of the Definition class: void Definition::put_word(char *s) {    word = new char[strlen(s)+1];    strcpy(word,s);    nmeanings = 0; }   voi

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