Write the program form Armstrong no in c++?

Answer Posted / tapojit roy

#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,x,sum=0;
clrscr();
printf ("the armstrong no. from 0 to 500 are\n");
for (n=1;n<=500;n++){
m=n;
while (m>0)
{
x=m%10;
sum=sum+(x*x*x);
m=m/10;
}
if (sum==n)
{
printf("%d\n",n);
}
sum=0;
}
getch();
}

Is This Answer Correct ?    29 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is java based off c++?

529


What is time h in c++?

585


If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?

634


What is the difference between a "copy constructor" and an "assignment operator" in C++?

618


How many keywords are used in c++?

554






Why c++ does not have finally?

587


What do you mean by vtable and vptr in c++?

619


What is a namespace in c++?

596


How many types of classes are there in c++?

590


What is an adaptor class in c++?

598


What are the advantages of inheritance in c++?

655


How a new operator differs from the operator new?

620


How to get the current position of the file pointer?

554


What is the full form of stl in c++?

674


What is atoi?

540