Write a program in C to generate and show the first 15 narcissistic decimal numbers
- برمجة سي c
- برمجة
- 2021-05-11
- MarwaMohammed
الأجوبة
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
int main()
{
printf("\n\n Find the first 15 narcissistic decimal numbers: \n");
printf(" -----------------------------------------------------\n");
printf(" The first 15 narcissistic decimal numbers are: \n");
int i,ctr,j,orn,n,m,sum;
orn=1;
for (i=1;i<=15;)
{
ctr=0;
sum=0;
n=orn;
while(n>0)
{
n=n/10;
ctr++;
}
n=orn;
while(n>0)
{
m=n % 10;
sum=sum+pow(m,ctr);
n=n/10;
}
if(sum==orn)
{
printf("%d ",orn);
i++;
}
orn++;
}
printf("\n");
} أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال