Horje
armstrong number in cpp Code Example
armstrong number in cpp
// armstrong or not

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int num, temp, i, j, rem, sum=0, power=0;

    cout<< "Enter the number: ";
    cin>> num;

    temp = num;

    for(i=1; temp!=0; i++)
    {
        rem = temp % 10;
        for(j=0; j<10;j++)
        {
            if (rem == j)
                power++;
        }
        temp = temp / 10;
    }

    temp = num;

    for(i=1; temp!=0; i++)
    {
        rem = temp % 10;
        sum = sum + pow(rem, power);
        temp = temp / 10;
    }


    if(sum == num)
        cout<< "armstrong" ;
    else
        cout<< "Not armstrong";

    return 0;
}




Cpp

Related
how to type cast quotient of two integers to double with c++ Code Example how to type cast quotient of two integers to double with c++ Code Example
c++ rainbow text Code Example c++ rainbow text Code Example
Reverse words in a given string solution in c++ Code Example Reverse words in a given string solution in c++ Code Example
create a file Code Example create a file Code Example
dream speedrun song mp4 Code Example dream speedrun song mp4 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10