C program to find Number is Armstrong or not. It is a simple source code that provides the output of an actual Armstrong number. Take care of a questions for your interviews or students exam. This is a totally free of cost code.
FIND NUMBER IS ARMSTRONG OR NOT IN C
Find the given number is Armstrong or not program in C used to detect the input number is Armstrong or not by calculating and sum the individual cube value of each number. If it is same to the given number then it will display an output. For example, the given number is 153(13+53+33=153) then it will be an Armstrong number.
[Read: Career Guidance for all] & [Aptitude Q&A free download]
C CODE:
Q: Write a C program to check whether a given input value is Armstrong number or not.
//Header files
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
//Program variables
int number,temp,number1,sum=0;
clrscr();//Function to clear previous output
printf("Enter number : "); //Display function
scanf("%d",&number); //Getting input function
temp=number;
//check number is Armstrong are not
while(number>0) //Unconditional statement
{
number1=number%10;
sum+=pow(number1,3);
number/=10;
}
if(sum==temp) //Conditional ststement
printf("Number is armstrong number");
getch();
}