Write the program form Armstrong no in c++?

Answer Posted / ramesh

#include<iostream.h>
#include<conio.h>
void main()
{
int sum=0,n,m;
clrscr();
cin>>n;
m=n;
while(n>0)
{
m=n%10;
sum=sum+(m*m*m);
n=n/10;
}
if(m==sum)
{
cout<<"the given number is amstrong";
}
else
{
cout<<"the given number is not amstrong";
}
getch();
}

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which operations are permitted on pointers?

658


Write a program to find the Fibonacci series recursively.

710


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

671


Why is "using namespace std;" considered bad practice?

746


How we can differentiate between a pre and post increment operators during overloading?

675






What's the best free c++ profiler for windows?

720


What are the advantages of using typedef in a program?

728


What is c++ prototype?

682


Why Pointers are not used in C++?

699


Why isn't sizeof for a struct equal to the sum of sizeof of each member?

625


How new/delete differs from malloc()/free?

710


I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

1665


How delete [] is different from delete?

682


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

697


What are the various storage classes in C++?

749