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

What is the average salary of a c++ programmer?

628


Are php strings immutable?

672


Is multimap sorted c++?

653


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

663


What is using namespace std in c++?

686






What are different types of loops in c++?

734


What are the characteristics of friend functions?

650


What is a loop? What are different types of loops in c++?

691


If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?

708


Difference between struct and class in terms of access modifier.

800


What is the use of :: operator in c++?

696


What are built-in functions? What is the syntax for the definition?

678


Explain the different access specifiers for the class member in c++.

636


What is a local reference?

780


Will this c++ program execute or not?

702