- C program to test if a number is a power of 2
- C program to multiply two number without using multiplication(*) operator
- C program to display Fibonacci series
- C program to compare two numbers without using relational operators
- C program to convert roman number into decimal number
- C program to encrypt and decrypt the string
- C program to make calculator using switch case
- C program to convert temperature from degree celsius to fahrenheit
- Selection sort in C programming
- Binary search in C programming
- C program to sort array using bubble sort algorithm
- Linear Search in C Programming – Program and Explanation
- C program to swap two numbers
- C program to find LCM of two numbers
- C program to find GCD of two numbers
- C program to find LCM and GCD using recursion
- C program to display prime numbers between two numbers using function and without using function
- C program to check whether a string is palindrome or not
- C program to read a character from keyboard and print it in reverse case i.e if input is lower case output will be upper case and vice versa
- C program to check whether a number is prime or not
- C program to check whether a number is positive, negative or zero
- C program to check whether a number is palindrome or not
- C program to check leap year
- C program to check Armstrong number
- C program to calculate the area of square with and without using function
- C program to calculate mean using arrays
- C program to calculate area of circle

In this article, you will learn the concept of** C program to check Armstrong number**.

**Armstrong Number**

A three digits number is said to be an Armstrong number if the sum of the cubes of its individual digit is equal to the number itself.

For example:

371 = 3*3*3 + 7*7*7 + 1*1*1

Please go through following articles of C programming to understand the concept of the program.

```
#include <stdio.h>
int main()
{
int num, temp, rem, sum = 0;
printf("Enter a three digit number: ");
scanf("%d", &num);
temp = num;
while (num != 0)
{
rem = num % 10;
sum += rem * rem * rem;
num = num / 10;
}
if (temp == sum)
printf("\n%d is an Armstrong number", temp);
else
printf("\n%d is not an Armstrong number", temp);
return 0;
}
```

Output

[adsense1]

```
#include <stdio.h>
#include <math.h>
int main()
{
int num, temp, rem;
int sum = 0, n = 0;
printf("Enter a number: ");
scanf("%d", &num);
temp = num;
//logic to find the number of digits in a given number
while (temp != 0)
{
temp = temp / 10;
n++;
}
temp = num;
while (temp != 0)
{
rem = temp % 10;
sum = sum + pow(rem, n);
temp = temp / 10;
}
if (num == sum)
printf("\n%d is an Armstrong number.", num);
else
printf("\n%d is not an Armstrong number.", num);
return 0;
}
```

**Output**

**Explanation**

In the second program, at first, we calculated the number of digits of the given number.

We used standard library function `pow`

to calculate the cube of the remainder.