// C program to check given number is
// Armstrong number or not using Sum 
// of Digits
#include <stdio.h>

// Driver code
int main()
{
	int n,r,sum=0,temp;
    printf("enter the number=");
    scanf("%d",&n);
    temp=n;
	// Calculating the sum of individual digits
	while (n > 0) 
    {
		r= n % 10;
		sum= sum + (r * r *r);
		n = n/10;
	}

	// Condition to check whether the
	// value of P equals to user input
	// or not.
	if (temp == sum) {
		printf("Yes. It is Armstrong No.");
	}
	else {
		printf("No. It is not an Armstrong No.");
	}
	return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: