Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Problem Statement - Armstrong numbers between 1 to 999
Print all the armstrong numbers between 1 to 999.
Solution
TC++ #1566
Run Output
1 153 370 371 407
Notes
If you are required to print only 3 digit armstrong numbers, start the first while loop from 100.
If armstrong numbers of higher than 1000 are desired than pow(rem,digits) function of math.h has to be used in place ofย num+=rem*rem*rem; Also number of digits have to be found before entering the second while loop.
Note: This question was deliberately asked from 1 to 999 as beyond 3 digits number this code won’t work.