Cast data type vs not casting - C Data Type

C examples for Data Type:Type Cast

Description

Cast data type vs not casting

Demo Code

#include <stdio.h>

int main( void )
{
   int i1 = 100, i2 = 40;
   float f1;/* w  w w.jav  a  2s .  c  o  m*/

   f1 = i1/i2;
   printf("%lf\n", f1);

   f1 = (float)i1/i2;
   printf("%lf\n", f1);

   f1 = (float)i2 + i1/i2;
   printf("%lf\n", f1);
   return 0;
}

Result


Related Tutorials