Write the program form Armstrong no in c++?

Answers were Sorted based on User's Feedback



Write the program form Armstrong no in c++?..

Answer / vinay k bharadwaj

dear frd your ans is wrong.


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

Is This Answer Correct ?    87 Yes 47 No

Write the program form Armstrong no in c++?..

Answer / saravanan

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

Is This Answer Correct ?    97 Yes 70 No

Write the program form Armstrong no in c++?..

Answer / 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

Write the program form Armstrong no in c++?..

Answer / rahul puri

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

Is This Answer Correct ?    48 Yes 41 No

Write the program form Armstrong no in c++?..

Answer / astitva srivastava

#include<iostream.h>
#include<conio.h>
void main()
{
int n,r,s=0;
cout<<"enter the no.";
cin>>n;
int b=n;
while(n>0)
{
r=n%10;
n=n/10;
s=s+(r*r*r);
}
if(b==s)
{
cout<<"the no. is armstrong"<<"\n";
}
else
{
cout<<"the no. is not a armstrong no.";
}
}

Is This Answer Correct ?    4 Yes 0 No

Write the program form Armstrong no in c++?..

Answer / ashish ranjan

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

Is This Answer Correct ?    13 Yes 10 No

Write the program form Armstrong no in c++?..

Answer / 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

Write the program form Armstrong no in c++?..

Answer / 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

Write the program form Armstrong no in c++?..

Answer / ramesh

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

Is This Answer Correct ?    4 Yes 3 No

Write the program form Armstrong no in c++?..

Answer / hitesh

Armstrong Program in C++

Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits is equal to the number itself.
For example 153 is armstrong number, 132 is not prime number. <a href="http://www.tutorial4us.com/cpp-program/cpp-armstrong-program" rel="nofollow">Armstrong program in c++</a> is very simple and easy to write.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.

0 Answers  


What is class and structure in c++?

0 Answers  


What is the oldest programming language?

0 Answers  


How do you declare A pointer to function which receives an int pointer and returns a float pointer

0 Answers  


Explain abstraction.

0 Answers  






Is c++ an oop?

0 Answers  


sir i want to study the c++ course but ino what is the qualification and the study methode please reply more details in c++

1 Answers   NIIT,


What do you mean by persistent and non persistent objects?

1 Answers  


Which software is best for coding?

0 Answers  


Incase of a function declaration, what is extern means?

0 Answers  


what do you mean by memory management operators

4 Answers   HCL,


what is Loop function? What are different types of Loops?

0 Answers  


Categories