Navigation

Saturday, 28 February 2015

Program for printing the armstrong number between 1 and 500



main()
{
    int i=1,a,b,c;
    clrscr();
    printf("the armstrong number between 1 and 500");
    while(i<=500)
    {
        a=i%10;
        b=i%100;
        b=(b-a)/10;
        c=i/100;
        if((a*a*a)+(b*b*b)+(c*c*c)==i)
        printf("%d\n",i);
        i++;
    }
    getch();
}

No comments:

Post a Comment