program to print number is armstrong or not


Armstrong number

students are often confused in terms? the most common term is an Armstrong number, hearing this the very first question which comes to our mind is that what is it?
what is the difference between a simple number and an Armstrong number?

are both same?
if yes then why don't we call them simple numbers?

yes both these are different numbers and these are special kind of numbers ,which can be found by the logic describe below .here
c4fun brings you the c program on this topic so that each and every topic is clear in your mind, go through the topic and if you have any doubt regarding the topic after that you can comment below, will for help you !!!

 C  code to check a number is an Armstrong or not ?.


before moving to code let us first understand some basics about the topic and then after move forward, it will make things easy to understand.
how to do that?
first, ask yourself
what is an Armstrong number?
 it is a number which is equal to the sum of digits raise to the power of a total number of digits present in a number.
below are some of the examples of such special numbers, you can find many once you have done the program but for the help, check out if your program is correct or not you may check out the following examples.

Some  are: 0, 1, 2, 3, 153, 370,

 First we find the number of digits and then find the sum of individual digits raise to power number of digits present in our input. 
If this sum equals the input number, the number is an Armstrong else not.

Examples:
7 = 7^1
371 = 3^3 + 7^3 + 1^3 (27 + 343 +1)



#include<stdio.h>
#include<conio.h>
void main()
{
int i,s,s=0,m;
clrscr();
printf("\n enter number");
scanf("%d",&n);
m=n;
while(m>0)
{
d=m%10;
s=s+(d*d*d);
m=m/10;
}
printf("sum of digits of  %d=%d",n,s);
if(n==s)
printf("\n armstrong");
else
printf("nope");
getch();
}





c4fun hope you have done the program and done with compile and running the program.
how was the experience?

did you find any new numbers?

was the number you were thinking of was found to be a special number or not?

do comment below on the number and result you have obtained, when you are done with programming.
happy coding....
and if you found the information useful do share it among your friends whom you think these things might help

do visit travel places for traveling blogs

3 comments:

thanks for reading and sharing.I hope it would help you!!!!

Powered by Blogger.