Armstrong Number in C Using For Loop

Armstrong number in c using for loop. Using this program we can find the number is Armstrong number or not for beginners to understand how to implement for loop in Armstrong number program. 

Armstrong Number Definition in C

An Armstrong number, also known as a narcissistic number, is the sum of its own digits’ cubes. 

As a result, narcissistic numbers are those that can be represented mathematically by manipulating their digits. The sum of a whole number’s digits’ nth powers is called an integer. 

For Loop Definition in C

In the C programming language, the for loop is used to iterate statements or parts of a program numerous times. 

It is commonly used to traverse data structures such as an array and a linked list. 

A for-loop (or simply for loop) is a control flow statement in computer science that specifies iteration and allows code to be executed repeatedly.

When the number of iterations is known before entering the loop, for-loops are commonly utilised. 

Armstrong Number in C Using For Loop

#include <stdio.h>
int main()
{
int num,r,sum=0,temp;
printf("Enter The Number");
scanf("%d",&num);
for(temp=num;num!=0;num=num/10)
{
r=num % 10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("%d is Armstrong Number\n",temp);
else
printf("%d is Not Armstrong Number\n",temp);
}

Output: 

Enter The Number153 

153 is Armstrong Number