Using the cast operator

Tuesday, October 14, 2014
/* 0604.c: Using the cast operator */
#include <stdio.h>

main()
{
    int x, y;

    x = 7;
    y = 5;
    printf("Given x = %d, y = %d\n", x, y);
    printf("x / y produces: %d\n", x / y);
    printf("(float)x / y produces: %f\n", (float)x / y);
    return 0;
}

Copyright @ 2015 Tron!

Labels

Blog Archive