title: Switch-Case Operator -- C
body: <p><strong>Is there a way to store user inputs in switch case from one operation and use it across switch operations at run-time.</strong></p>
  <p><strong>Example:</strong> If its a software for a Bank and I want to take information from the user and validate if his a/c number is correct and also check if he has enough bank balance to withdraw money.</p>
  <p>I need to know how to store the value of one operation,so that I could use it for further ops.</p>
  <pre><code> switch(ops)
      {
  
                              char ac_no;
                              long amt,amt2,init_dep;
                              char name,ac_allocated;
  
  
              case OpenAC:
                      {
                              printf(&quot;1.Name:\n&quot;);
                              scanf(&quot;%s&quot;,&amp;name);
  
                              printf(&quot;2.A/Cno_allocated:\n&quot;);
                              scanf(&quot;%s&quot;,&amp;ac_allocated);
  
                              printf(&quot;3.Initial deposit:\n&quot;);
                              scanf(&quot;%d&quot;,&amp;init_dep);
                              break;
  
                      }
              case Deposit:
                      {
                              printf(&quot;Enter the a/c number: &quot;);
                              scanf(&quot;%s&quot;,&amp;ac_no);
  
                              printf(&quot;Amount:Rs. &quot;);
                              scanf(&quot;%ld&quot;,&amp;amt);
                              break;
  
                      }
              case Withdraw:
                      {
                              printf(&quot;Enter the a/c number: &quot;);
                              scanf(&quot;%s&quot;,&amp;ac_no);
  
                              printf(&quot;Amount:Rs. &quot;);
                              scanf(&quot;%ld&quot;,&amp;amt2);
  
  
                    {printf(&quot;Cannot withdraw.Rs.500 minimum balance mandatory.\n&quot;);}
  
                              break;
  
                      }
              return ops;
  
      }
  </code></pre>
  <p>I also tried declaring variables in the switch(ops) to store the value in them(like in the following case to validate the a/c number in the next step but it doesn't help.)</p>
  <p><strong>Edited code:</strong></p>
  <p>`</p>
  <pre><code>                            char ac_no;
  
                              long amt,amt2,init_dep,dep1;
  
                              char name,ac_allocated,ac1;
  
                 case OpenAC:
                      {
                              printf(&quot;1.Name:\n&quot;);
                              scanf(&quot;%s&quot;,&amp;name);
  
                              printf(&quot;2.A/Cno_allocated:\n&quot;);
                              scanf(&quot;%s&quot;,&amp;ac_allocated);
  
                              ac_allocated = ac1;
  
                              printf(&quot;3.Initial deposit:\n&quot;);
                              scanf(&quot;%d&quot;,&amp;init_dep);
                              init_dep = dep1;
  
                              //break;
  
                      }
              case Deposit:
                      {
                              printf(&quot;Enter the a/c number: &quot;);
                              scanf(&quot;%s&quot;,&amp;ac_no);
  
                              if(ac_no == ac1)
                              {
                               printf(&quot;Amount:Rs. &quot;);
                               scanf(&quot;%ld&quot;,&amp;amt);
                              }
  
                              break;
  </code></pre>
  <p>`</p>