मराठी

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

Advertisements

प्रश्न

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

कोड लेखन
लघु उत्तर
Advertisements

उत्तर

#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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2022-2023 (March) Official
Advertisements
Share
Notifications



      Forgot password?
Use app×