Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
121 views

Armstrong Number C Program - Programming Simplified

This C program checks if a number is an Armstrong number. An Armstrong number is a number whose sum of the cubes of its digits is equal to the number itself. The program takes a number as input, calculates the sum of the cubes of its digits and compares it to the original number. If they are equal, it prints that the number is Armstrong, otherwise it is not Armstrong. The code includes functions to extract each digit using the remainder operator and raise it to the power of three to calculate the cube.

Uploaded by

Srimoy Supkar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

Armstrong Number C Program - Programming Simplified

This C program checks if a number is an Armstrong number. An Armstrong number is a number whose sum of the cubes of its digits is equal to the number itself. The program takes a number as input, calculates the sum of the cubes of its digits and compares it to the original number. If they are equal, it prints that the number is Armstrong, otherwise it is not Armstrong. The code includes functions to extract each digit using the remainder operator and raise it to the power of three to calculate the cube.

Uploaded by

Srimoy Supkar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

10/10/12

armstrong number c program | Programming Simplified

Home C programming C programming examples armstrong number c program

armstrong number c program


armstrong number c program: c programming code to check whether a number is armstrong or not. A number is armstrong if the sum of cubes of individual digits of a number is equal to the number itself. For example 371 is an armstrong number as 33 + 7 3 + 1 3 = 371. Some other armstrong numbers are: 0, 1, 153, 370, 407.

C programming code
# i n c l u d e< s t d i o . h > m a i n ( ) { i n tn u m b e r ,s u m=0 ,t e m p ,r e m a i n d e r ; p r i n t f ( " E n t e ran u m b e r \ n " ) ; s c a n f ( " % d " , & n u m b e r ) ; t e m p=n u m b e r ; w h i l e (t e m p! =0) { r e m a i n d e r=t e m p % 1 0 ; s u m=s u m+r e m a i n d e r * r e m a i n d e r * r e m a i n d e r ; t e m p=t e m p / 1 0 ; } i f(n u m b e r= =s u m) p r i n t f ( " E n t e r e dn u m b e ri sa na r m s t r o n gn u m b e r . " ) ; e l s e p r i n t f ( " E n t e r e dn u m b e ri sn o ta na r m s t r o n gn u m b e r . " ) ; r e t u r n0 ; }

Output of program:

C programming: C programming examples

Guest (not verified)


Thu, 23/06/2011 - 13:41 per m a lin k

It work's
Abov e program runs without any errors. Thanks....
reply

Guest (not verified)


Mon, 01/08/2011 - 17:15 per m a lin k

very good.....!!!!
v ery good.....!!!!

www.programmingsimplified.com/c-program-find-armstrong-number

1/2

10/10/12
reply

armstrong number c program | Programming Simplified

Guest (not verified)


Sun, 14/08/2011 - 17:31 per m a lin k

help
i didn't get this!
reply

adminPs
Mon, 15/08/2011 17:00 per m a lin k

Explanation
It will be added to content.
reply

Guest (not verified)


Mon, 15/08/2011 - 16:19 per m a lin k

what is armstrong number


what is armstrong number
reply

adminPs
Mon, 15/08/2011 16:59 per m a lin k

definition of armstrong number


See content abov e.
reply

Guest (not verified)


Fri, 19/08/2011 - 15:16 per m a lin k

thanks
It work's v ery good...!!!
reply

Guest (not verified)


Sat, 27/08/2011 - 15:18 per m a lin k

it's became very helpful for


it's became v ery helpful for me,thanks....
reply

www.programmingsimplified.com/c-program-find-armstrong-number

2/2

You might also like