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

Does dev c++ support c++ 11?

550


What is ifstream c++?

557


Array base access faster or pointer base access is faster?

1813


Is map thread safe c++?

628


What is implicit pointer in c++?

600






What is ios class in c++?

578


Write a function to find the nth item from the end of a linked list in a single pass.

566


Explain about templates of C++.

675


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

2034


What are the differences between new and malloc?

628


Should a constructor be public or private?

536


Explain object slicing in c++?

585


Keyword mean in declaration?

592


What is the main use of c++?

549


What do you mean by friend class & friend function in c++?

620