answersLogoWhite

0

Why goto in c is a bad command?

Updated: 8/10/2023
User Avatar

Wiki User

16y ago

Best Answer

A 'goto' statement immediately moves the execution of code to another part of the program. This makes the code difficult to follow and to debug. It is better practice to use If-then-else constructs to structure the program code.

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

goto statement isn't a programming habit. Over-using goto statement is a bad habit; makes the code hardly-readable.

(Note: let's not forget that break, continue and return are variations of goto.)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why goto in c is a bad command?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a c for goto statement?

AGAIN: puts ("c"); goto AGAIN;


What is the purpose of goto statement in c?

The purpose of goto is to skip over code and gotoa named label.Goto is not as bad to use as you will read in many places, goto has a bad name from BASIC where gotoproduced spaghetti code that was impossible follow and understand.In C you can only goto go to a named label in the same function that the goto statement is in. The named label can be prior or post of the goto statement.Goto is very useful (in a limited scope) to jump over a bunch of if statements that are redundant because it has already been established that a particular section of code in the function needs to be executed. Judicious use of goto can improve the human readability of the code and also improve the programs performance.


List of command used in c language?

It's easy: there are no commands in C, but a few statements (such as: expression, if, else, switch, while, do-while, for, break, continue, return and goto), and countless library functions (like printf, malloc and fopen).


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.

Related questions

Write a c for goto statement?

AGAIN: puts ("c"); goto AGAIN;


What command is used to move to a specific cell address in an Excel worksheet?

The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.The Goto command, which you can activate by pressing the F5 key. You could also type the cell address into the name box.


Why is goto statement harmful?

It isn't. True, you can write bad code with goto, but you can do that without goto as well.


Is it true or false that you use the go to command to get a closer view of a worksheet in Microsoft Excel?

False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.False. The Goto command can bring you to different parts of the worksheet and select some cells, but it doesn't zoom in and make it larger.


What is the purpose of goto statement in c?

The purpose of goto is to skip over code and gotoa named label.Goto is not as bad to use as you will read in many places, goto has a bad name from BASIC where gotoproduced spaghetti code that was impossible follow and understand.In C you can only goto go to a named label in the same function that the goto statement is in. The named label can be prior or post of the goto statement.Goto is very useful (in a limited scope) to jump over a bunch of if statements that are redundant because it has already been established that a particular section of code in the function needs to be executed. Judicious use of goto can improve the human readability of the code and also improve the programs performance.


Need help to create a batch program to display a menu of four choices using DOS?

Choice is a command used under DOS Batch file to get input from user and then execute the command written under particular errorlevel. @ECHO OFF :START CLS ECHO. ECHO. ECHO 1. Exit 2. Continue choice/c:12 " Enter your choice if errorlevel 2 goto STAGE1 goto end :STAGE1 copy <File Name > to c:\<Directory Name> goto end


What is the shortkey for GOTO menu in MS-Word?

You can press the F5 key. You can also press Ctrl-G. Both will activate the Goto command for you.


How is information located in Excel?

It is stored in cells and you can locate it using the Find command, or by setting up named cells and using the GoTo command to get to them. Cells are identified by their column letters and row numbers. So cell C3 is in column C and row 3.


List of command used in c language?

It's easy: there are no commands in C, but a few statements (such as: expression, if, else, switch, while, do-while, for, break, continue, return and goto), and countless library functions (like printf, malloc and fopen).


How can you locate a bookmark in Microsoft?

You can use the Goto command, which can be started by using the Ctrl - G shortcut.


What excel command allows you to move to a cell quickly?

Goto. You can activate it by pressing the F5 keys.


Why goto statements are not available in java?

Using "goto", even in languages where it is available, is generally considered bad programming practice.