int a, i = 5.156546; i = 5 because i is integer. try int a; double d = 5.156546; a = (int) d; or print printf("%.0f\n", d);