What is the use of goto statement?

C Programming Language >   Control Flow in C Programming >   goto Statement in C  

Short Question

875


Answer:

goto statement is used to transfer the normal flow of a program to the specified label in the program. Below is the syntax for goto statement in C.


{
 </p>
                                          
                                        <hr>
                                        
                              <div style="text-align:center">
                              <a href="#list" class="btn btn-info btn-sm main-gradient-tutorials">Go to Question List</a>
                              </div>
                              
                              <div class = "shadow p-3 mt-2" style = "border-radius: 10px;">
                               <div class='col m-3'><p> <i class='fa fa-info-circle'></i> <small>This Particular section is dedicated to <b>Question & Answer</b> only. If you want learn more about <b>C Programming Language</b>. Then you can visit below links to get more depth on this subject.  </small></p></div><div class='col m-3'><div class="row">
     <div class="col bg-light m-2 shadow btn btn-success"> <a href="https://www.atnyla.com/syllabus/c-programming-language/1"> C Syllabus </a> </div>
     <div class="col bg-light m-2 shadow btn btn-success">   <a href="https://www.atnyla.com/tutorial/about-c-tutorial/1/152">C Tutorial </a> </div>  
     <div class="col bg-light m-2 shadow btn btn-success"> <a href="https://www.atnyla.com/fundamentals-of-c-language/1/20">C Chapterwise Programs </a>  </div> 
     <div class="col bg-light m-2 shadow btn btn-success"> <a href="https://www.atnyla.com/general-knowledge/88/158">C Chapterwise MCQs </a> </div>
     <div class="col bg-light m-2 shadow btn btn-success"> <a href="https://www.atnyla.com/qa/fundamentals-of-c-language/1/20">C Chapterwise Q & A </a> </div>

    <div class="col bg-light m-2 shadow btn btn-success"> <a href="https://www.youtube.com/watch?v=I_DwOci2mtE&list=PL2Bn5-JgUDvfFxrUDJg0E9FqoxLjth5fo" rel="nofollow">C Free Videos </a> </div>
</div>
<hr></div><hr style='height:3px;border-width:0;color:gray;background-color:gray'>                              </div>
                                 
                              <br>
                             <div class="shadow p-3 mb-5 bg-body rounded">
                               <a href="/tutorial/about-c-tutorial/1/152" class="btn btn-sm btn-default"># C Tutorials</a> 
                               <a href="/tutorial/java/0/0" class="btn btn-sm btn-default"># JAVA Tutorials</a>
                               <a href="/tutorial/about-html5-tutorial/2/233" class="btn btn-sm btn-default"># HTML Tutorials</a>
                           
                              <a href="https://www.atnyla.com/tutorial/about-tutorial/6/395" class="btn btn-sm btn-default"># Computer Fundamental</a> 
                               <a href="https://www.atnyla.com/tutorial/about-dsa/3/295" class="btn btn-sm btn-default"># Data Structure</a>
                               <a href="https://www.atnyla.com/tutorial/about-dbms-tutorial/13/713" class="btn btn-sm btn-default"># DBMS Tutorials</a>
                           
                              <a href="https://www.atnyla.com/tutorial/about-sql-tutorial/5/355" class="btn btn-sm btn-default">SQL</a> 
                               <a href="https://www.atnyla.com/tutorial/about-c-tutorial/8/468" class="btn btn-sm btn-default"># C# Language</a>
                               <a href="https://www.atnyla.com/tutorial/about-r-tutorial/7/409" class="btn btn-sm btn-default"># R Language</a>
                            
                              <a href="https://www.atnyla.com/tutorial/about-php-tutorial/12/604" class="btn btn-sm btn-default"># PHP</a> 
                               <a href="https://www.atnyla.com/tutorial/about-python-tutorial/11/597" class="btn btn-sm btn-default"># Python</a>
                               <a href="https://www.atnyla.com/tutorial/about-vue-js-tutorial/14/765" class="btn btn-sm btn-default"># Vue JS</a>
                             </div>
                             
                             <hr>
                             <h3>Join Our telegram group to ask Questions </h3>
                             <p> Click below button to join our groups. </p>
                             <div class="row">
                                 <div class="col m-2 bg-light shadow btn btn-success">
                                   <a href="https://t.me/atnyla"  rel="nofollow" target="_blank"> Ask Question - CSE </a>
                                 </div>  
                                  <div class="col m-2 bg-light shadow btn btn-success">
                                    <a href="https://t.me/ComputerLanguageWithRumman"  rel="nofollow" target="_blank"> Programming Language - PDF</a>
                                </div> 
                            </div>
                                        
                              <br>
                               
                            </div> 
                        </div>
                    </div>
                   <div class="col-lg-5">
                
                            <ul class="list-group" >
                                <li id="list" class="list-group-item d-flex justify-content-between align-items-center main-gradient-tutorials mb-2"><strong>Related Program List</strong></li>
                                         <div class="list-group divStyleQuestion" style="border:1px solid #e0e0e0;padding:8px">
            <div class="d-flex w-100 justify-content-between">
              <a href="/qanswer/what-value-will-be-assigned-to-the-variable-x-if-a-10-b-20-c-30-d-40-for-the-expression-x-a-b-c-d-c-question/25/650">
                  <h5 class="mb-1" style="color:#194757;">650. &nbsp;What value will be assigned to the variable X if a = 10, b = 20, c = 30, d = 40 for the expression X = a/b+c*d-c?</h5>
              </a>
            </div>
                            <div class="card">
                  <div class="card-body">
                     Answer: <ul>
<li>The above arithmetic operation is performed based on the precedence of the operators.</li>
<li>In above mentioned expression, c*d will be performed first. Then, a/b, then (c*d)-c, then (a/b) + ((c*d)-c).</li>
<li>Please check the operator precedence table to know the priority and associativity of the C operators.</li>
<li>Output of the above expression is 1170.</li>
</ul>
<pre class="prettyprint">
<xmp>

2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
   int a = 10, b = 20, c = 30, d = 40, X ;
 
   X = a/b+c*d-c;
   printf(" Value of X = %d\n", X);
   return 0;
}