What happens when type casting is not leveraged during integer division. - C Data Type

C examples for Data Type:Type Cast

Description

What happens when type casting is not leveraged during integer division.

Demo Code

#include <stdio.h> 
int main() /*from   w  w  w  . j a  v  a2  s  .c  o  m*/
{ 
   int x = 12; 
   int y = 5; 
   printf("\nWithout Type-Casting\n"); 
   printf("12 \\ 5 = %.2f\n", x/y); 
   printf("\nWith Type-Casting\n"); 
   printf("12 \\ 5 = %.2f\n", (float) x / (float) y); 
}

Related Tutorials