title: Store user-input in a variable
body: <p>I was wondering how I could prompt the end-user of my program to type in a value they want to be converted from Fahrenheit into Celsius in C.</p>
  
  <p>Basically, since I'm a total n00b and I'm writing amazing "programs" such as this one:</p>
  
  <pre><code>    //Simple program to convert Fahrenheit to Celsius
  
      int main (int argc, char *argv[])
      {
       double celsius, fahrenheit, result;
  
       celsius = result;
       fahrenheit = 27;
       result = (fahrenheit - 32) / 1.8;
  
       printf("27 degress Fahrenheit is %g degrees Celsius!", result);
  
       return 0;
      }
  </code></pre>
  
  <p>I would like to add some actual "functionality" to it if you know what I mean.  Instead of just making this a test program where really it just shows off some simple arithmetic expression evaluating, I would like to actually make it somewhat mildly useful.</p>
  
  <p>Anyway, I was wondering if I could use the function listed in the <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/scanf.3.html" rel="nofollow noreferrer">scanf(3) Man page</a> to aid me in the recognition of user-inputted data, and then somehow store it into the Fahrenheit variable.</p>
  
  <p>Now, it would really be cool if the program, upon running, could prompt the end-user with a question asking whether he or she would like to convert from Celsius to Fahrenheit or from Fahrenheit to Celsius, but let's just take it one step at a time, and I'll wait until I read the chapter in my book about "Making Decisions"! :)</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Removes useless variable result as pointed out by kiamlaluno:</p>
  
  <pre><code>    //Simple program to convert Fahrenheit to Celsius
  
      int main (int argc, char *argv[])
      {
   double fahrenheit, celsius;
  
   fahrenheit = 27;
   celsius = (fahrenheit - 32) / 1.8;
  
   printf("27 degress Fahrenheit is %g degrees Celsius!", celsius);
  
   return 0;
      }
  </code></pre>
  
  <p><strong>UPDATE UPDATE:</strong></p>
  
  <p>I've been trying to incorporate everyone's helpful suggestions posted here, but I'm running into more problems with my code:</p>
  
  <pre><code>//Simple program to convert Fahrenheit to Celsius and Celsius to Fahrenheit
  
  int main (int argc, char *argv[])
  {
  int celsius, fahrenheit, celsiusResult, fahrenheitResult;
  celsiusResult = (fahrenheit - 32)*(5/9);
  fahrenheitResult = (celsius*(9/5)) + 32;
  int prompt;
  
  printf("Please press 1 to convert Fahrenheit to Celsius, or 0 to convert Celsius to Fahrenheit please:\n ");
  scanf("%i", &amp;prompt);
  if(prompt == 1) {
      printf("Please enter a temperature in Fahrenheit to be converted into Celsius!:\n");
      scanf("%i", &amp;fahrenheit);
      printf("%i degress Fahrenheit is %i degrees Celsius!", fahrenheit, celsiusResult);
  
  }
  else {
      printf("Please enter a temperature in Celsius to be converted into Fahrenheit:\n");
      scanf("%i", &amp;celsius);
      printf("%i degreses Celsius is %i degrees Fahrenheit", celsius, fahrenheitResult);
  }
  
  return 0;
  }
  </code></pre>
  
  <p>Everything's working great, except for the calculations themselves, which come out completely wrong..
  For a second I thought this may have been because I changed the numbers themselves to integers types, but I made them doubles again and it was still kind of screwy.</p>
  
  <p>Any thoughts?</p>