C语言获取数值的最后几位数

 

#include <stdio.h>

int main(void)
{
    int num;
    puts("please input a number:");
    printf("num: ");scanf("%d",&num);
    printf("the last digit of num is: %d\n", num % 10);  ## 获取最后一位数
    return 0;
}

##int类型的取值范围是-32767到32767

 

posted @ 2020-12-25 13:59  小鲨鱼2018  阅读(1284)  评论(0编辑  收藏  举报