If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
वो numbers जिसमे हर digit के cubes का total उस number के बराबर होता है , उन्हें Armstrong numbers कहते हैं।
कुछ Armstrong Numbers इस प्रकार हैं -
1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834 ये सभी Armstrong numbers हैं।
सबसे पहले ऊपर दिए गए numbers को check कर लेते हैं कि ये number Armstrong हैं या नहीं। तो जैसा कि अभी आपने ऊपर पढ़ा कि अगर number , इसमें present हर digit के cubes के total के बराबर होना चाहिए।
11 = 1 21 = 2
इसी तरह से 153 , हालाँकि इसमें 3 digit हैं इसीलिए हर digit पर 3 की घात होगी।
13 = 1 55 = 125 33 = 27 Total : 1 + 125 + 27 = 153
इस article में C language में हम Armstrong number check करने के लिए एक program बनाएंगे।
#include <stdio.h>
#include <math.h>
int main()
{
int num, originalNum, remainder, n = 0, result = 0;
printf("Enter an integer: ");
scanf("%d", &num);
originalNum = num;
// store the number of digits of num in n
for (; originalNum != 0; ++n) {
originalNum /= 10;
}
// reset originalNum to num
originalNum = num;
while (originalNum != 0) {
remainder = originalNum % 10;
result += pow(remainder, n);
originalNum /= 10;
}
if (result == num)
printf("%d is an Armstrong number.", num);
else
printf("%d is not an Armstrong number.", num);
}
Loading ...
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook