title: (Float) Typecast in C
body: <p>I am currently learning C and typecasts and it is suggesting that if I want to convert an int to a float I should precede the variable with <code>(float)</code> to do this.  </p>
  
  <p>However, when I don't use the typecast, the answer still comes out correct, even though I am mixing the ints and floats. </p>
  
  <p>Can someone explain why/when I would need to use the typecast <code>(float)</code> in particular?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      int A, B, E;
      float C, D;
  
      A = 2;
      B = 1;
      C = 12.5;
  
      D = C * A + B;
      E = C * A + B;
  
      printf("Total is %.1f\n", D);
      printf("total is %d", E);
      return 0;
  }
  </code></pre>