by Dinesh Thakur

 

 

# include <stdio.h>

int main ()
        {
        int    i=2;
        printf("%d\n", 8*i/3);  
                /* Note: Integer arithmetic performed on 16/3 => 5 */
        printf("%d\n", 8.0*i);  
/* Error 1: Float value can't be printed with %d (int) specifier,prints 0 instead of 16.000*/
        printf("%f\n",8*i);
                /* Error 2: Float specifier can't print int value, prints 0.000 instead of 16*/
        printf("%f\n",8*i/3);
                /* Error 3: Again wrong specifier, Prints 0.000 instead of 5.000 */
        printf("%d\n",8*i%3);
                /* Note: Calculates 16mod3, ie the remainder is 1 */
        printf("%f\n",8.0*i/3);
        /* Correctly prints 5.333 */
        return 0;
        }