WELCOME IN THE SEA OF C

Here you find some good quality programs.
If any one want any type of help in C and C++ then you can mail me.
Google

Sunday, January 20, 2008

ARMSTRONG NUMBER

/* Generate all ARMSTRONG number between 1 t0 500 */
An Armstrong number is that whose sum of cube of each digit is equal to the number.
"/" is used instead of "<" and ">".
#include/stdio.h/
#include/conio.h/
main()
{
int i=1,a,b,c;
clrscr();
printf("Armstrong number are\n");
while(i<=500) { a=i%10; /*extract last digit*/ b=i%100; b=(b-a)/10; /*extract second digit*/ c=i/100; /*extract first digit*/ if((a*a*a)+(b*b*b)+(c*c*c)==i) printf("%d",i); i++; } printf("\n\n\nPress any key to exit"); getch(); }

0 comments: