Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

armstrong number using function in c

#include<stdio.h>
#include<conio.h>
void arm(int a);
int main()
{
	int a;
	printf("			Enter a number
			 ");
	scanf("%d",&a);
	arm (a);
	getch();
	return 0;
}
void arm(int a)
{
	int b,sum,remainder;
	b=a;
	while (a>0)
	{
		remainder=a%10;
		sum=sum+(remainder*remainder*remainder);
		a=(a-remainder)/10;
	}
	if (b==sum)
	{
		printf("	
It is armstrong number
");
	}
	else
	{
		printf("
	It is not armstrong number
");
	}
}
 
PREVIOUS NEXT
Tagged: #armstrong #number #function
ADD COMMENT
Topic
Name
2+9 =