Write the program form Armstrong no in c++?

Answer Posted / ankit,rohit

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

Is This Answer Correct ?    20 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a multiset c++?

555


Tell me an example where stacks are useful?

596


What is general format for a prototype?

601


What is conditions when using boolean operators?

607


What is #include sstream?

628






What is anonymous object in c++?

632


What causes a runtime error c++?

591


What are the advantages of c++?

598


What is a far pointer? where we use it?

621


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

602


What is flush c++?

541


On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

683


Evaulate: 22%5 a) 2 b) 4 c) 0

672


How do you establish an is-a relationship?

625


What is meant by const_cast?

653