English

Write a C++ program to find entered number is Armstrong number OR NOT armstong: - Computer Science 1

Advertisements
Advertisements

Question

Write a C++ program to find entered number is Armstrong number OR NOT armstong:

Code Writing
Short Answer
Advertisements

Solution

#include<iostream.h>
#include<conio.h>
void main()
{
    int n, dn, temp, d;
    cout<<"Enter a number";
    cin>>n;
    dn = n;
    temp=0;
    while(dn!=0)
   {
        d=dn%10;
        temp=temp+(d*d*d);
        dn=dn/10;
    }
    if(n==temp)
    {
        cout<<n<<" is armstrong no.";
    }
    else
    {
        cout<<n<<" is not an armstrong number";
    }
}
shaalaa.com
  Is there an error in this question or solution?
2022-2023 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×