title: declaration shadows a local variable in c
body: <p>I am using the cs50 library and ide and when trying to compile this program I get errors saying that the variable 'answer' has already been declared and I don't know how to solve this any answers would be appreciated I am really stuck on this as I have just began to learn how to program the error log is:</p>
  <pre><code>char.c:9:14: error: declaration shadows a local variable [-Werror,-Wshadow]
          char answer = get_char(&quot;are you okay&quot;)
  
  char.c:6:10: note: previous declaration is here
      char answer;
  
  char.c:20:12: error: variable 'answer' is uninitialized when used here [-Werror,-Wuninitialized]
      while (answer != 'y' &amp;&amp; answer != 'Y' &amp;&amp; answer != 'n' &amp;&amp; answer != 'N');
  
  char.c:6:16: note: initialize the variable 'answer' to silence this warning
      char answer;
  </code></pre>
  <p>The code is:</p>
  <pre><code>#include &lt;cs50.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(void)
  {   
      char answer;
      do
      {
          char answer = get_char(&quot;are you okay Y/N &quot;);
          if (answer == 'y' || answer == 'Y')
          {
              printf(&quot;you are okay&quot;);
          }
              else if (answer == 'n' || answer == 'N')
          {
              printf(&quot;you are not okay &quot;);
          }
  
      }
      while (answer != 'y' &amp;&amp; answer != 'Y' &amp;&amp; answer != 'n' &amp;&amp; answer != 'N');
  }
  </code></pre>