已知在c语言中运算符%可以实现取余操作, 即: 8%5的计算结果是3,定义一个整型

已知在c语言中运算符%可以实现取余操作, 即: 8%5的计算结果是3,定义一个整型

变量并输入任意一个整数,利用% 运算显示该数字的个位上的数字

第1个回答  2008-11-27
#include <stdio.h>
void main()
{
int n,m;
printf("请输入一个正整数:");
scanf("%d",&n);
m=n%10;
printf("%d\n",m);
}

参考资料:敲键盘

本回答被提问者采纳
第2个回答  2008-11-27
这个很简单,无论你输入多少位的数字,只要%10,结果总是个为数!
#include<stdio.h>
main()
{
int num;
printf("请输入一个整型数字:");
scanf("%d",&num);
num=num%10;
printf("%d\n",num);
}
第3个回答  2008-11-27
//对C的输入输出不是很熟悉~~
#include "stdio.h"

int main(){
long int a;
printf("Please input the numerical value you want: ");
scanf("%d",&a);
printf("The last number of the number is: ");
printf("%d",a%10);
printf("\n");
return 0;
}
第4个回答  2008-11-27
#include<stdio.h>
void main()
{
int a,b;
scanf("%d",&a);
b=a%10;
printf(" b=%d\n",b);
}
相似回答