
输入数字N,取出给定数字的个位数并显示该数字的倍数。
输入− N=326
输出− 个位数为 6,其倍数为 2 和 3
注意 − 任何数字的个位数都可以通过计算 %10 来获取数字
婚纱影楼小程序提供了一个连接用户与影楼的平台,相当于影楼在微信的官网。它能帮助影楼展示拍摄实力,记录访客数据,宣传优惠活动。使用频率高,方便传播,是影楼在微信端宣传营销的得力助手。功能特点:样片页是影楼展示优秀摄影样片提供给用户欣赏并且吸引客户的。套系页是影楼根据市场需求推出的不同套餐,用户可以按照自己的喜好预定套系。个人中心可以查看用户预约的拍摄计划,也可以获取到影楼的联系方式。
0
例如 - 如果给你一个数字 N 并且你需要找到它的个位数字
你可以使用 N%10 它将返回你的数字个位数字N
START
Step 1 -> Declare start variables num, num2 and i
Step 2 -> input number num
Step 3 -> store num%10 in num2 to fetch unit digit
Step 4 -> print num2
Step 5 -> Loop For i=2 and i<=num2/2 and ++i
IF num2%i=0\
Print i
End IF
Step 6 -> End For Loop
STOP#include<stdio.h>
int main() {
int num,num2,i;
printf("</p><p>enter a number");
scanf("%d" , &num);
num2=num%10; //storing unit digit in num2
printf("</p><p> unit digit of %d is: %d",num,num2);
for(i=2;i<=num2/2;++i) { //loop till half of unit digit
if(num2%i==0) { //calculate multiples
printf("</p><p> multiple of %d is : %d ",num2,i);
}
}
return 0;
}如果我们运行上面的程序,那么它将生成以下输出
enter a number329 unit digit of 329 is: 9 multiple of 9 is : 3
以上就是在C程序中打印给定数字的个位数的倍数的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号