mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2024-12-22 05:12:40 +00:00
tells if a number is an hashard number or not
This commit is contained in:
parent
03035efd1d
commit
8096c39974
29
code/hashard.c
Executable file
29
code/hashard.c
Executable file
@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define n 10
|
||||
int num,count,i,sum;
|
||||
char buff[n];
|
||||
int a[n];
|
||||
int main(){
|
||||
|
||||
printf("Enter a number: ");
|
||||
scanf("%d",&num);
|
||||
snprintf(buff,n,"%d\n",num);
|
||||
printf("%s\n",buff);
|
||||
count =strlen(buff)-1;
|
||||
printf("%d\n",count);
|
||||
snprintf(num,n,"%s\n",buff);
|
||||
for(i=0;i<(count-1);i++){
|
||||
a[i] = buff[i];
|
||||
}
|
||||
for(i=0;i<(count-1);i++){
|
||||
printf("%d\n",a[i]);
|
||||
}
|
||||
|
||||
printf("A hashard num is one which is divisibe by the sum of its individual digits\n");
|
||||
printf("e.g 27 is hashard bc 27/(2+7) = \"0\"\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user