Write the program form Armstrong no in c++?

Answer Posted / sarang deshpande

#include<iostream.h>
#include<conio.h>
void main()
{
int n,n1,sum,rem;
clrscr();
cout<<" \n Enter a num ";
cin>>n;
n1=n;
sum=0;
while(n>0)
{
rem=n%10;
sum=sum+(rem*rem*rem);
n=n/10;
}
if(n1==sum)
{
cout<<"\n The number is armstrong "<<n1;
}
else
{
cout<<"\n The number is not armstrong "<<n1;
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why are pointers used?

654


What is the maximum combined length of command line arguments including the space between adjacent arguments?

669


What is array in c++ example?

748


Do inline functions improve performance?

737


What are the different types of comments allowed in c++?

677






Does a derived class inherit or doesn't inherit?

718


Explain function overloading

666


What is scope in c++ with example?

724


What is a multimap c++?

775


What is functions syntax in c++?

713


Is main a class in c++?

641


Who invented turbo c++?

731


what is oops and list its features in c++?

644


In c++, what is the difference between method overloading and method overriding?

698


Can we define a constructor as virtual in c++?

689