C Language

June 3, 2023

How to use Armstrong number in C Language

Program to use Armstrong number in C Language


#include <stdio.h>
int main(void)
{
    int num, n, cube, d, sum;
    printf("armstorng numbers are :\n");
    for (num = 100; num <= 999; num++)
    {
        n = num;
        sum = 0;
        while (n > 0)
        {
            d = n % 10;
            n /= 10;
            cube = d * d * d;
            sum = sum + cube;
        }
        if (num == sum)
            printf("%d\n", num);
    }
    return 0;
}

output


armstrong number are :
153
370

by : Nadeem Khan

Quick Summary:

Program to use Armstrong number in C Language copy #include <stdio.h> int main(void) { int num, n, cube, d, sum; printf(“armstorng numbers are :\n”); for (num = 100; num