title: Functions and returning values in C
body: <p>Im trying to print out the part at the end of this program. I enter C17 and the part comes out as 0 when it should be 1. Why is this?</p>
  
  <p>Kind Regards</p>
  
  <p>Dennis </p>
  
  <pre><code># include &lt;stdio.h&gt;
  int Part; 
  int getPartType(int Part);
  int calcPrice(int Part);
  
  
  int main(int argc, char * argv[]){
  
      getPartType(Part);     
      calcPrice(Part);
      return 0;
  }
  
  // Part1: Asks for input from user for part type
  int getPartType(int Part) {
      int nvr;
      char character_one;
      char character_two;
      int number;
  
      printf("Enter the part type (C17, F25, DN3, GG7 or MV4): ");
      nvr = scanf("%c%c%d",&amp;character_one,&amp;character_two,&amp;number);
  
      if (number==7 &amp;&amp; character_two=='1') {
          Part=1;
      }else if (number==5 &amp;&amp; character_two=='2') {
          Part=2;
      }else if (number==3 &amp;&amp; character_two=='N') {
          Part=3;
      }else if (number==7 &amp;&amp; character_two=='G') {
          Part=4;
      }else if (number==4 &amp;&amp; character_two=='V') {
          Part=5;
      }else{
          printf("Wrong Part Type\n");
          Part=0;
      }
  
      return Part;
  }
  
  int calcPrice(int Part) {
  
      printf("%d\n",Part);
      return 0;
  }    
  </code></pre>