Submitted by tushar pramanick on Fri, 03/08/2013 - 00:21

The goto Statement

I feel that this book would not be not complete without mentioning the goto statement, although I do not recommend that you use the goto statement unless it's absolutely necessary. The main reason that the goto statement is discouraged is because its usage may make the C program unreliable and hard to debug.

The following is the general form of the goto statement:

labelname:
   statement1;
   statement2;
   .
   .
   .
   goto  labelname;


Here labelname is a label name that tells the goto statement where to jump. You have to place labelname in two places: One is at the place where the goto statement is going to jump (note that a colon must follow the label name), and the other is the place following the goto keyword. You have to follow the same rules to make a label name as you name a variable or function.

Also, the place for the goto statement to jump to can appear either before or after the statement.

Related Items

Exercises : Answer the following Question

After Reading and Understanding the Chapter 01 : How To Start C programming, please give the answer of following Questions. If you able to answer these question correctly then please proceed to Write My First C Program.

Question and Answer

Questions and Answers on Chapter 03 : "The Essentials of C Programs". Some Questions and their answers are given bellow for better understanding of Chapter 03 : The Essentials of C Programs . If any body ask any question please write in comment page or forum.

C প্রোগ্রাম Function এর ভিতরের অংশের আলোচনা

The Function Body

The function body in a function is the place that contains variable declarations and C statements. The task of a function is accomplished by executing the statements inside the function body one at a time.

C প্রোগ্রামিংয়ে Function কে কিভাবে কল করবেন ?

Making Function Calls

Based on what you've learned so far, you can write a C program that calls the integer_add() function to calculate an addition and then print out the result on the screen. An example of such a program is demonstrated in Listing 3.2.