title: Declaring a method after main method produces error in c
body: <p><strong>This Code Compiles Correctly</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
      void printMessage()
      {
        printf("HELLO WORLD\n");
      }
  
      int main()
      {
       printMessage();
  
      return 0;
      }
  </code></pre>
  
  <p><strong>This Piece of Code Produces an error</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      printMessage();
  
  return 0;
  }
  void printMessage()
  {
    printf("HELLO WORLD\n");
  }
  </code></pre>
  
  <p>The only difference is that in the first piece of code, the void method is written before the main method and in the the second piece of code the void method is written after the main method. However when I compile the second piece of code I get the following: 
  <img src="https://i.stack.imgur.com/7yOkl.png" alt="enter image description here"></p>
  
  <pre><code>hello.c:13:7: warning: conflicting types for 'printMessage' (enabled by default)
  hello.c:7:2: note: previous implicit declaration of 'printMessage' was here
  </code></pre>
  
  <p>It could be something ridiculous I apologize in advance as I am brand new to C. Please advise.</p>