Skip to content
Home » C Programs » Armstrong Number in C Using Function

Armstrong Number in C Using Function

Simple armstrong number in c using function. In this program, we can find whether the number is an Armstrong number or not using a function in the c program for beginners.

Armstrong Number Definition

The sum of the cubes of its own digits is equal to an Armstrong number, also known as a narcissistic number. 

As a result, narcissistic numbers are numbers that can be represented by manipulating their digits mathematically. 

A whole number, or integer, is the sum of its digits’ nth powers. 

Function Definition in C

A function is a collection of statements that work together to complete a task. 

Every C program contains at least one function, main(), and even the simplest programs can specify more functions. 

The name, return type, and parameters of a function are all specified in a function declaration. 

Armstrong Number in C Using Function

//armstrong number in c using function
#include<stdio.h>
int func(int number)
{
int num = 0;
int power = 0;
int sum = 0;
int n = number;
while(n!=0)
{
num = n % 10;
power = num*num*num;
sum += power;
n /= 10;
}
if(sum == number) return 0;
else return 1;
}
int main()
{
int number;
printf("Enter The Number");
scanf("%d",&number);
if(func(number) == 0)
printf("%d is Armstrong Numbern", number);
else
printf("%d is Not Armstrong Number", number);
return 0;
}

Output: 

Enter The Number45 

45 is Not Armstrong Number 

LCM of Two Numbers in C Using Recursion 

C Program for LCM of Two Numbers Using Functions 

Armstrong Number in C Using For Loop 

Linear Search in C Program Using Array 

Insertion Sort Program in C Using Array 

Bubble Sort Program in C Using Function 

Bubble Sort in C Program Example 

Binary Search in C Program Using Function 

C Program to Find Reverse of a String Using Recursion 

C Program to Implement Quick Sort Using Recursion 

Binary releases – Code::Blocks

GDB online Debugger | Compiler – Code, Compile, Run, Debug online C, C++

Online Compiler and Editor/IDE for Java, C/C++, PHP, Python, Perl, etc

C (programming language)

Applications of C Programming That Will Make You Fall In Love With C