Goto Statement in C language | goto program in c programming | C notes

Goto Statement in C language | goto program in c programming | C notes

Goto Statement in C Language 

In the C programming language, the goto statement is used to transfer control to a labeled statement within the same function or block of code. It allows you to jump from one part of your code to another, which can be useful in certain situations. However, the use of goto is generally discouraged and considered bad practice because it can lead to hard-to-read and error-prone code. In structured programming, it's recommended to use control structures like loops and conditional statements (if-else) to control the flow of your program instead of using goto.

Goto Statement in c language



Here's the basic syntax of the goto statement in C:


goto statemnt in c language


goto is the keyword.

label is an identifier that marks the destination where you want to jump.
Here's an example of how you can use goto:

goto program in c language

 

In this example, a label named start is defined before an if statement. The program uses goto to jump back to the start label as long as the condition i < 5 is true. This code will print the numbers from 0 to 4.



Again, it's important to note that using goto should be avoided in most cases because it can make your code less readable and harder to maintain. Instead, use structured programming constructs like loops (e.g., for, while, do-while) and conditional statements (e.g., if, else) to control the flow of your program.

 

watch video For More Details 
 

 

 

All C  Topics : -

  1. C Language Intro

  2. Structure of C Language 

  3. Variable & data Types 

  4. Printf and Scanf Function

  5. Operator in c Language 

  6. If Statement in c Language 

  7. If else and Nasted if in C

  8. Switch Case In C 

  9. While loop in C Language 

  10. Exit Control Loop (Do While)

  11. For Loop in c 

  12. C Language Pratice Program 

  13. Goto Statement in c Programming 

  14. Array in c

  15. Pointer in  c Language 

  16. String in c Language 

Post a Comment (0)
Previous Post Next Post