Armstrong number or not ?

Discussion in 'C++' started by hkp819, Dec 30, 2008.

  1. hkp819

    hkp819 New Member

    Joined:
    Dec 4, 2008
    Messages:
    59
    Likes Received:
    1
    Trophy Points:
    0
    hello friend I am learning c++.
    I want to create program to write to find a given number is Armstrong number or not ?
     
  2. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    OK, so how would you do it on paper? Is 23 an Armstrong number? Why or why not? Show your working. You can then use that working to determine an algorithm, and from that you can write the program.
     
  3. rohitphulsunge

    rohitphulsunge New Member

    Joined:
    Jan 11, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Nagpur, Maharashtra, India
    armstrong number is that number which is equal to the sum of the individual digit's cube
     
  4. debrah.h48

    debrah.h48 New Member

    Joined:
    Nov 12, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    Try this
    Code:
    main()
    
    {
    
    int amm 0 temp 0 n x;
    
    printf( enter thealue of n );
    
    scanf( d &n);
    
    x n;
    
    for(;n>0;)
    
    {
    
    temp n 10;
    
    amm amm+(temp*temp*temp);
    
    n n/10;
    
    }
    
    if(x n)
    
    {
    
    printf( THE GIVEN NUMBER IS AMSTRONG NUMBER );
    
    }
    
    else
    
    printf( NOT AMSTRONG NUMBER );
    
    }
     
  5. rohitphulsunge

    rohitphulsunge New Member

    Joined:
    Jan 11, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Nagpur, Maharashtra, India
    Rohit Phulsunge says-
    Yes the above code for armstrong number would work
    ..!!:)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice