Wednesday 28 March 2012


TO DISPLAY AMSTRONG NUMBERS UP TO A GIVEN NUMBER




#include<stdio.h>
#include<math.h>
Void main()
{
Int sum,num,n,digit,temp;
Clrscr();
Printf(“up to which number ?”);
Scanf(“%d”&n);
Printf(“amstong numbers up to %d are:\n”);
For(num=1;num<=n;+}+num)
{
For(temp=num,sum=0;temp>0;temp/=10)
{
Digit=temp%10;
Sum+=pow(digit,3);
}
If(num==sum)
Printf(“%d\t”,num);
}
Getch();
}

No comments:

Post a Comment