Find the Armstrong number in cpp

 How to find the Armstrong number in the cpp programming language?







Here , you will find the solution to the problem to find the Armstrong number in cpp. Following is the code to find the Armstrong number.First,you know 
What is Armstrong Number?

A positive number which the sum of cube power of every digit is equal to the original number is called the Armstrong number. For example:

armstrong number in cpp
Armstrong Number


Code:

#include <iostream>
using namespace std;

int main() {
    int numb, original, rem, result = 0;
    cout << "Enter a three-digit integer: ";
    cin >> numb;
    original= numb;

    while (original != 0) {
        
        rem = original % 10;
        
        result += rem * rem * rem;
        
        
        original /= 10;
    }

    if (result == numb)
        cout << numb << " is Armstrong number.";
    else
        cout << numb << " is not Armstrong number.";

    return 0;
}

Output:
Enter a three-digit integer: 153
153 is an Armstrong number.

Comments

Popular posts from this blog

Diferrence between flutter and react native

Flutter Widgets

Flutter layout