// Harshad Number
#include<stdio.h>
int main()
{
int n,sum=0,REM,TEMP;
printf("Enter a number:");
scanf("%d",&n);
TEMP = n;
while(n>0)
{
REM=n%10;
sum=sum+REM;
n=n/10;
}
if(TEMP%sum==0)
{
printf("%d is Harshad Number\n",TEMP);
}
else
{
printf("%d is not a Harshad Number\n",TEMP);
}
return 0;
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.