GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Knowledge Base  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 12 of 40    Print  
Why to avoid goto in C

C has GOTO statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us see what the goto statement does, its syntax and functionality. The goto is a unconditional branching statement used to transfer control of the program from one statement to another.

Syntax of goto statement is:

goto namel;
………….. ………….
…………. ………….
…………. ………….
name1:
Statement;

Here in the goto the name1 mentioned identify the place where the branch is to be made. The name1 is a valid variable name followed by a colon. The name1 is placed immediately before the statement where the control is to be transformed. A program may contain several goto statements that transferred to the same place when a program in which case the names mentioned in goto must be unique for branching. Control can be transferred out of or within a compound statement, and control can be transferred to the beginning of a compound statement. However the control cannot be transferred into a compound statement.

Thus one must take care not to use too much of goto statements in their program or in other words use it only when needed. This is because C being a highly structured language one must take care not to use too much of these unconditional goto branching statements which makes the program a poor way of coding. The goto statement is discouraged in C, because it alters the sequential flow of logic that is the characteristic of C language. This word is redundant in C and encourages poor programming style.




  
Total Answers and Comments: 0 Last Update: July 03, 2006     Asked by: GeekAdmin 
  
 Sponsored Links

 

 

 

No answers are posted for this question yet.
Be the first to answer it!


 Related Questions

C has GOTO statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions 
View Question | Asked by : GeekAdmin

longjmp() and setjmp() functions implement a nonlocal jump of program execution."longjmp" jumps to a program state previously recorded by "setjmp". Both longjmp() and setjmp() functions 
View Question | Asked by : GeekAdmin

This can be done using extern C Syntax of extern C is: extern "C" That is for calling C functions from C++ we can write as extern "C" {  
View Question | Asked by : GeekAdmin

The main role of header file is it is used to share information among various files. To put it brief, if we have several functions say 4 functions named as f1, f2, f3, f4 placed in file say sample.c 
Latest Answer : we r using numerous predefined c functions like,printfsqrtscanfgetchmallocFILENULLif strcmp etc, these functions coding,prototype,execution are defined and categorized and stored in different files while we user while programing we use this functions ...


 Sponsored Links

 

 

 
Related Articles

Knowledge Management in Business Networks

What is Knowledge Management KM The basic definition of knowledge management from the business perspective states that it is the vital set of methods that manage the conception distribution and exploitation of knowledge In today’ s Information Age era with the technological advancements in
 

C++ Pure Virtual Function and Base Class

C Pure Virtual Function and Virtual Base Class In this C tutorial you will learn about pure virtual function declaration of pure virtual function and virtual base class virtual base class and how to implement a virtual base class explained with examples mosgoogle center What is Pure Virtual Function
 

Base Address of the String

What happens when we try to change the value of base address of the string? The base address of the sting takes a special place in the context of strings. This is because suing this base address only the string gets identified. In other words the base address therefore takes the position of constant
 

goto Statement

Why to avoid goto in C C has goto statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us understand the goto statement, its
 

Avoid Common English Mistakes in Your Resume

Avoid Common English Mistakes in Your Resume When it comes to getting a good job your resume is a factor that will play a pivotal role in your success or failure While I ve talked about the importance of using proper English during the job interview you won t even get this far if your resume isn t h
 

What To Avoid During Formal Conversation

What To Avoid During Formal Conversation In a formal social scenario it would take more than good clothes and a pleasant looking appearance to be able to present yourself well How you converse with the hosts and their other guests can say a lot about your social skills mosgoogle In some circles espe
 

How To Avoid Failure When Implementing CRM

How To Avoid Failure When Implementing CRM While Customer relationship management systems can be a bonanza to companies that utilize them properly they can be costly if a company fails to properly implement them In addition to this the relationship that companies have with their customers can be tre
 

Avoid Mistakes When Sponsoring a Project

Avoid Mistakes When Sponsoring a Project If you are a sponsor who is looking to complete a project there are a number of things you will want to avoid Doing the things described in this article will likely lead to failure and it can cost you a great deal of time and money In some cases your reputati
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

Group Discussion - How To Avoid Problems During Group Discussions

How To Avoid Problems During Group Discussions When you are participating in a group discussion it is important to avoid problems that will stop the group from achieving its goals If you are the leader or planner there are a number of things you will want to pay attention to mosgoogle It is importan
 

Related Categories
    Sponsored Links

     

     

     
    About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

    Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved

    Page copy protected against web site content infringement by Copyscape