0% found this document useful (0 votes)
50 views2 pages

Armstrong No

An Armstrong number is a number where the sum of each digit raised to the power of the number of digits equals the number. The program takes a user input number, calculates the number of digits, extracts each digit and raises it to the power of the number of digits, sums the results and checks if it equals the input number to determine if it is an Armstrong number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Armstrong No

An Armstrong number is a number where the sum of each digit raised to the power of the number of digits equals the number. The program takes a user input number, calculates the number of digits, extracts each digit and raises it to the power of the number of digits, sums the results and checks if it equals the input number to determine if it is an Armstrong number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A number is called Armstrong number when the sum of the nth power of each digit is equal to the

given number. Here ‘n’ is the total number of digits in a number.

#include <stdio.h>

#include<math.h>

void main() {

int num, var, rem, sum = 0, a = 0 ;

printf ( "Enter an integer:" ); // Taking the user input

scanf ( "%d", &num );

var = num;

while (var != 0) // Finding the numbers of digits in a given number

var = var / 10;

++a;

var = num;

while (var > 0 ) // Calculate the number to check it is Armstrong or not

rem = var % 10;

sum = sum + pow( rem, a );

var = var / 10;

if ( sum == num ) // Check whether the sum is equal to the given number of not

printf ( "%d is an Armstrong number \n", num );

else

{
printf ( "%d is not an Armstrong number \n", num );

You might also like