answersLogoWhite

0

The goto statement is a control flow statement that causes the CPU to jump to another spot in the code. This spot is identified through use of a statement label. The following is an example of a goto statement and statement label:1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

#include <iostream>

#include <cmath>

int main()

{

using namespace std;

tryAgain: // this is a statement label

cout << "Enter a non-negative number";

double dX;

cin >> dX;

if (dX < 0.0)

goto tryAgain; // this is the goto statement

cout << "The sqrt of " << dX << " is " << sqrt(dX) << endl;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is go-to unconditional in c plus plus?

An unconditional goto is a goto that has no associated conditional expression. The following example demonstrates conditional and unconditional goto statements. int x=rand(); if (x) goto label_1; // conditional goto (when x is non-zero) else goto label_2; // conditional goto (when x is zero) label_1: // ... goto label_3; // unconditional goto (jump past label_2) label_2: // ... label_3: // ...


Which statement is not frequently used in C plus plus?

The goto statement.


Is there any keyword in c or c plus plus like the function inkey in qbasic?

Using TurboC? kbhit and getch are your friends


What is use of keyword extra in c plus plus programming?

Nothing.


What is meant by println in c plus plus?

println is not a C++ keyword.


What is CPU usage small programm c plus plus?

Example: int main (void) { LOOP: goto LOOP; }


How java use extern key word which is used in C plus plus?

No extern keyword in Java.


Is it possible to declare a keyword as an identifier in c plus plus?

No. Keywords are reserved and cannot be used as identifiers. However, C/C++ is case-sensitive. So although register is a reserved keyword, Register is not.


Instantiation of objects in c plus plus?

Objects are instantiated when statically declared or dynamically created with the new keyword.


What is friendly in c plus plus?

The keyword "friend" allows a function or variable to have access to a protected member inside a class.


How does the use of the 'void' keyword differ in C plus plus vs. C?

It doesn't. Void has the same meaning in both.


Why are goto calls so bad in C plus plus?

The Goto call is considered bad for several reasons: - the call itself is almost superfluous, and the method that it is used in can always be achieved by using another form of manipulation. For example, if you wanted to break out of a loop by using a goto, you could achieve the same results by writing 'break;.' - code is meant to be structured and easy to understand. Because goto calls can be placed anywhere in code, it breaks up the structure, making it difficult to follow. - because the CPU has to read through the entire program to find the corresponding goto call, it is very memory inefficient.