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

What is difference c and c++?

1 Answers  


What are activex and ole?

0 Answers  


How Virtual functions call up is maintained?

2 Answers  


How to reduce a final size of executable?

3 Answers  


write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.

0 Answers  






What do manipulators do?

0 Answers  


What gives the current position of the put pointer?

0 Answers  


How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?

0 Answers  


How would you represent an error detected during constructor of an object?

1 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

4 Answers   Webyog,


Define a conversion constructor?

0 Answers  


an operation between an integer and real always yeilds a) integer result b) real result c) float result

0 Answers  


Categories