GoogelAddUnit1

Friday 26 August 2011

Write a C Program to check whether the given number is Am strong or Not.?


#include<stdio.h>
#include<conio.h>
void main()
{
int dn,rem,sum,n;
printf("Enter the number:");
scanf("%d",&n);
for(dn=n,sum=0;n!=0;rem=n%10,sum=sum+rem*rem*rem,n=n/10);
if(dn==sum)
printf("Amstrong number");
else
printf("Not a amstrong number");
}

Armstrong number:-

The sum of the cubes of digits of a number is equal to the original number.
Ex: n=153 => 13 + 53 +33 = 1+125+27= 153
so 153 is arm strong number.


No comments:

Post a Comment