//Checking Armstrong number for a variable length of number
#include <stdio.h>
#include <math.h>

void main(){
    int num,r,sum=0,temp,Nnum,count;
    printf("Input  a number: ");
    scanf("%d",&num);
    Nnum=num;
    temp=num;
    printf("\nNnum = %d \n",Nnum);
    printf("temp = %d \n",temp);
    
    while(Nnum!=0){
        count=count +1 ;
        Nnum/=10;
    }
    printf("Count = %d",count);
    for(;num!=0;num=num/10){
         r=num % 10;
         sum=sum+pow(r,count);
    }
    if(sum==temp){
         printf("\n%d is an Armstrong number.\n",temp);}
    else{
         printf("\n%d is not an Armstrong number.\n",temp);}

}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: