C Program 3 – To check whether a number is Armstrong Number

The armstrong number is of the form 153= 13 + 53 + 33

The input is : 153 or any other number

output: The number is armstrong or not.

Processing: take 153 as an example, remove 3, 5 and 1 in the reverse order (using % operator) and take the power of 3 and add to the sum variable.

if the total sum and the original number, both are same, then that is the arm strong number.

if else, the number is not an armstrong number

#include <stdio.h>
#include <conio.h>

int main()
    int original_num, check, temp, sum=0;
    printf("Enter the number to check for armstrong number");
    scanf("%d", &original_num);
// Get the original number
//run the loop till the number becomes 0
//remove the last digit using modulo operator
     sum=sum+check*check*check; //the last digit is taken power to 3 and added to sum
     original_num=original_num/10; //truncate the last digit and run the loop again
     printf("This is an armstrong numbern");
     printf("This is not an armstrong number n");
     return 0;

5 thoughts on “C Program 3 – To check whether a number is Armstrong Number”

Leave a Reply