Write the program form Armstrong no in c++?

Answer Posted / roshan patel

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,d;
cout<<"\nEnter the no : ";
cin>>x;
y=x;
int sum=0;
while(y>0)
{
d=y%10;
y/=10;
sum=sum+d*d*d;
}
if(x==sum)
cout<<"\n "<<x<<" is Armstrong ";
else
cout<<"\n"<<x<<" is not Armstrong";
getch();
}

Is This Answer Correct ?    17 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between pass by value and pass by reference?

597


If dog is a friend of boy and boy is a friend of house, is dog a friend of house?

547


What is meant by entry controlled loop? What all C++ loops are exit controlled?

559


Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.

2090


What is constructor c++?

668






Define vptr.

594


What is the use of typedef?

633


Can comments be longer than one line?

617


What causes a runtime error c++?

581


Explain the benefits of proper inheritance.

638


What is the difference between reference and pointer?

610


What is c++ programming language?

576


What does the linker do?

589


What are arithmetic operators?

537


What is public, protected, private in c++?

651