A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C to generate and show the first 15 narcissistic decimal numbers
Q:

Write a program in C to generate and show the first 15 narcissistic decimal numbers

0

Write a program in C to generate and show the first 15 narcissistic decimal numbers


Expected Output :
The first 15 narcissistic decimal numbers are:
1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

# 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");
} 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now