Sunday, April 5, 2020

C Program For Armstrong Number | C Programming Example

Learn About Armstrong Number With C Programming Example : -


This Article From Learn c programming in Hindi Will help you to learn About "C Program For Armstrong Number" and check out "selection sort program in c", "socket programming in c", "merge sort program in c","Kruskal's algorithm in c", "for loop c programming", "c struct example","simple program in c language", "simple CPP program", "c programming practice questions", "c program using for loop", "programming using c", "hello world program in c", "if statement in c ".


C Programming Example
C Programming Example


किसी संख्या के अंकों का योग, कुल अंकों की संख्या को बढ़ाता है, आर्मस्ट्रांग संख्या है।

आर्मस्ट्रांग संख्या उदाहरण: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634 आदि।

स्पष्टीकरण:

3 = 3 ^ 1 = 3

153 = 1 ^ 3 + 5 ^ 3 + 3 ^ 3 = 153

गैर-आर्मस्ट्रांग संख्या:

156 = 1 ^ 3 + 5 ^ 3 + 6 ^ 3। यह मान 342 के बराबर है। इसलिए, 156 एक आर्मस्ट्रांग संख्या नहीं है

Source Code For Armstrong Number In C Program Example


	
#include 
 
int main()
 
{
 
   int n, sum = 0, t, remainder;
 
   printf("\nPlease enter a number to find whether it is an armstrong or not");
 
   scanf("%d",&n);
 
 
 
   t = n;
 
 
 
   while( t != 0 )
 
   {
 
      remainder = t%10;
 
      sum = sum + remainder*remainder*remainder;
 
      t = t/10;
 
   }
 
   if ( n == sum )
 
      printf("\nThe number %d is an armstrong number", n);
 
   else
 
      printf("\nThe number %d is not an armstrong number", n);
 
   return 0;
 
}


0 Comments:

Post a Comment