Bhuvan InfoTech Android App

Download our Android App and browse Technical News, Projects, Computer Tricks more easily with lots of Interesting Features.

Tuesday, June 14, 2016

Check number is Armstrong or Not | C program

#include <stdio.h>

int main()
{
    int n, no, last, sum = 0;

    printf("Type number to check Armstrong or not : ");
    scanf("%d", &n);

 
    no = n;

    while(n != 0)
    {

        last = n % 10;
       

        sum += (last * last * last);

        n = n / 10;
    }


    if(no == sum)
    {
        printf("\n%d is Armstrong", no);
    }
    else
    {
        printf("\n%d is not Armstrong", no);
    }

    return 0;
}
Bhuvan Arora

No comments:

Amazing Deal !