Armstrong Number In C Programming Language

Armstrong Number In C is the number that is equal to the sum of all digits to the power of the total number of digits in that number. To understand better check this example given below:
Eg:- The Number 153 which is an Armstrong number
Let’s Prove that this number is Armstrong number:
Total digits in number = 3
1^3 = 1*1*1 = 1
5^3 = 5*5*5 = 125
3^3 = 3*3*3 = 9
S0, 153 = (1*1*1)+(5*5*5)+(3*3*3)
153= 1+125+27 , Hence Proved
Armstrong Number In C Program Code:
#include<stdio.h> int main() { int num,r,sum=0,temp; printf("enter the number="); scanf("%d",&num); temp=num; while(num>0) { r=num%10; sum=sum+(r*r*r); num=num/10; } if(temp==sum) printf("armstrong number "); else printf("not armstrong number"); return 0; }
Still having difficulty to understand, then you can watch this video to understand Armstrong number program:
Try Best Ide For C programming Language: Turbo c++
No Comments