C语言判断一个数是否是小数

#include <stdio.h>  
#include <math.h>  
  
int main() {  
    double num = 3.14;  
    double int_part = floor(num);  
  
    if (num == int_part) {  
        printf("The number is an integer.\n");  
    } else {  
        printf("The number is not an integer (i.e., it has a fractional part).\n");  
    }  
  
    return 0;  
}

全部评论

相关推荐

投递恒生电子股份有限公司等公司7个岗位
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务