Ans:->
The program to check whether a given number is an Armstrong number or not in C Language :-
What si an Armstrong Number❓
An armstrong number is a number which is equal to the sum of the cubes of its individual digits. For example 153 is an Armstrong number.
153 = (1)^3 + (5)^3 + (3)^3
153 = 1 + 125 + 27
153 = 153
Algorithm for the Armstrong program is as follows:-
START:-
(1) Take integer variable.
(2) Assign value to the variables.
(3) Split all digits.
(4) Find cube value of each digits.
(5) Add all cube values Together
(6) Save the output to sum variables.
(7) If sum equals to arms print Armstrong Number.
(8) If sum not equals to arms print NOT a Armstrong Number.
STOP-----
Program is as follows:--
#include<stdio.h>
int main()
{
int n,r,sum=0,temp;
printf("Enter the Number=");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("Armstrong Number ");
else
printf("Not Armstrong Number");
return 0;
}
OUTPUT:---
Enter the Number = 125
Not Armstrong Number
Do You Know the answer for this question:-
Click on the Link for the Answer 👇👇
C EXERCISE: Program to display the sum of the series [ 9 + 99+ 999 + 9999 ...] in C Language:------
C EXERCISE: Program to convert positive integer number to its binary equivalent in C Language:-----
THANKU FOR READING THIS ARTICLE ON-
If you want to suggest any changes in the program please feel free to contact us in the comment section or you can reach us using Contact us Page.
0 Comments
If you want to give any suggestion regarding the post please feel free to Comment below-