C Program to check given number is Armstrong Number or not.

Spread the love

Armstrong Number Program in C:

  1. #include<stdio.h>
  2. int main()
  3. {
  4.    int num,rem,temp,sum;
  5.    printf(“Enter any Number : “);
  6.    scanf(“%d”,&num);
  7.  
  8.    temp = num;
  9.    sum = 0;
  10.    while(num > 0)
  11.    {
  12.       rem = num % 10;
  13.       sum = sum + (rem*rem*rem);
  14.       num = num / 10;
  15.    }
  16.  
  17.    if(sum == temp)
  18.    {
  19.       printf(“Given Number %d is Armstrong Number n,temp);
  20.    }
  21.    else
  22.    {
  23.       printf(“%d is not a Armstrong Number n, temp);
  24.    }
  25.    return 0;
  26. }

Output :

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply