Armstrong Number Check
Armstrong Number is a three digit number such that the sum
of the cubes of the digits of the number is equal to the number itself,
i.e, xyz = x3+y3+z3
Eg, 153 = 13+53+33
Given below is a program for a Armstrong number test using C++:
You can however write the code in a different way. This is just a sample.Open C++
Write the code:
#include <stdio.h>
#include <conio.h>
void main ()
{
int x,m,sum,temp;
sum=0;
printf ("Enter number\n");
scanf ("%d",&x);
temp=x;
while (x>1)
{m=x%10;
x=x/10;
sum=sum+(m*m*m);}
if (sum==temp)
{printf ("\n%d is an Armstrong Number",temp);}
else {printf ("\n%d is not an Armstrong Number",temp);}
}
Run the code.
It works.
To save, use extension .cpp
Thanks!
ConnectU Edu.
TO KNOW MORE OR TO CLARIFY YOUR DOUBTS ON THE TOPIC, PUT A COMMENT.REMARKS, SUGGESTIONS AND QUERIES ARE WELCOME. JUST PUT A COMMENT.
Click here to download the Armstrong Number Checker Program for FREE
It works.
To save, use extension .cpp
Thanks!
ConnectU Edu.
TO KNOW MORE OR TO CLARIFY YOUR DOUBTS ON THE TOPIC, PUT A COMMENT.REMARKS, SUGGESTIONS AND QUERIES ARE WELCOME. JUST PUT A COMMENT.
Click here to download the Armstrong Number Checker Program for FREE