Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

check Armstrong number

 C++ Program to check the input number is Armstrong number or not.
Armstrong number c++ program:  A number is armstrong if the sum of cubes of individual digits of a number is equal to the number itself. For example 371 is an armstrong number as 33 + 73 + 13 = 371. Some other armstrong numbers are: 0, 1, 153, 370, 407.


Source Code:-


#include<iostream.h>
#include<conio.h>

void main()
{ clrscr();
  int temp,num,sum=0,r;
  cout<<"Program to check Armstrong condition by-Tarun Rawat\n\n";
  cout<<"Enter a number : ";
  cin>>num;
  temp=num;
  while(num!=0)
       {r=num%10;
       num=num/10;
       sum=sum+(r*r*r);
       }
  if(sum==temp)
    cout<<endl<<temp<<" is a Armstrong number. \n";
  else cout<<endl<<temp<<" is not a Armstrong number./n";
getch();
}

3 comments:

Blogger Widgets

Find Us On Google, Just type - way2cplusplus -

If you have any questions on implementing or understanding this C++ Program , shoot me a comment and I'll be glad to help! :) :)