C Program For Armstrong Number Using Function

C Program:

/* Aim: Write a program for the following function prototype
void isArmstrong(int n)*/


#include<stdio.h>

void isArmstrong(int n); // isArmstrong Function Prototype

void main()
{
	int n;

	printf("\n Enter any number:- ");
	scanf("%d",&n);

	isArmstrong(n);
}

// isArmstrong Function
void isArmstrong(int n)
{

	int r,sum=0,original;

	original=n;

	while(n>0)
	{
	r=n%10;
	sum=sum+r*r*r; n=n/10; 
	}
	if(original==sum)
		printf("\n %d is Armstrong number \n \n",original); 
	else
		printf("\n %d is not Armstrong number \n \n",original);

} // End of the code

/* Output of above code:-

 Enter any number:- 153

 153 is Armstrong number 

*/