mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
Add files via upload
adding disarm number check
This commit is contained in:
parent
247267b834
commit
83e4427b3e
30
disarium.c
Normal file
30
disarium.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include<math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int n,i=0,j,sum=0,l,k;
|
||||
scanf("%d",&n);
|
||||
k=n;
|
||||
j=k;
|
||||
while(n>0)
|
||||
{
|
||||
d=n%10;
|
||||
n=n/10;
|
||||
i++;
|
||||
}
|
||||
while(k>0)
|
||||
{
|
||||
l=k%10;
|
||||
sum=sum+pow(l,i);
|
||||
k=k/10;
|
||||
i--;
|
||||
}
|
||||
if(j==sum)
|
||||
{
|
||||
printf("It is an disarium number");
|
||||
}
|
||||
else
|
||||
printf("It is not disarium number");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user