Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to write a loop program in c language that will ask for a number and send

ID: 3652023 • Letter: I

Question

I have to write a loop program in c language that will ask for a number and send that number from main to a function that determines if it is a narcassistic number. if it is the function returns 1 as an int to main. if it is not a narcasistic number it is suppose to return 0

A Narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits.
The function should return 1 if it is a Narcissistic number else it should return 0.
For example, 1634 is a Narcissistic number as 1^4 + 6^4 + 3^4 + 4^4 = 1 + 1296 + 81 + 256 = 1634
Similarly, 407 is a Narcissistic number as 4^3 + 0^3 + 7^3 = 64 + 0 + 343 = 407

I have the program written to find narcassistic numbers only with three digits such as 407. but I need to modify it so it can find any narcassistic number here is what I have so far

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//void drawCheckerboard(int size);
int isNarcissistic(long number);
int main(void)
{
int number, decision;
printf("Enter a number to check if it is an Armstrong number ");
scanf("%d", &number);
decision=isNarcissistic(number);
if (decision==1)
{
printf("%d is an Armstrong number! ", number);
}
if (decision==0)
{
printf("%d is not an Armsrong number! ", number);
}

return EXIT_SUCCESS;
}
int isNarcissistic(long number)
{
long temp, sum=0, remainder;
temp=number;
while(temp!= 0)
{
remainder=(temp%10);
sum =(sum+pow(remainder, 3));
temp=(temp/10);
}

if(number==sum)
return(1);
else
return(0);
}

Explanation / Answer

int isNarcissistic(long number) { long temp, sum=0, remainder,count = 0; temp=number; while(temp!= 0) { ++count; temp=(temp/10); } temp = number; while(temp!= 0) { remainder=(temp%10); sum =(sum+pow(remainder, count)); temp=(temp/10); } if(number==sum) return(1); else return(0); } // First count the number of digits in the number and then use it while computing the power of each digit