ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C++ >> C++ General
 
 


 

 
 STL interview questions  STL Interview Questions (90)
 OOPS interview questions  OOPS Interview Questions (554)
 C++ General interview questions  C++ General Interview Questions (458)
Question
Write the program form Armstrong no in c++?
 Question Submitted By :: Vijay_it4all
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write the program form Armstrong no in c++?
Answer
# 1
#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 ?    95 Yes 70 No
Saravanan
 
  Re: Write the program form Armstrong no in c++?
Answer
# 2
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 ?    85 Yes 45 No
Vinay K Bharadwaj
 
 
 
  Re: Write the program form Armstrong no in c++?
Answer
# 3
#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 ?    46 Yes 41 No
Rahul Puri
 
  Re: Write the program form Armstrong no in c++?
Answer
# 4
#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
Tapojit Roy
 
  Re: Write the program form Armstrong no in c++?
Answer
# 5
#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 ?    19 Yes 22 No
Ankit,rohit
 
  Re: Write the program form Armstrong no in c++?
Answer
# 6
#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 ?    12 Yes 10 No
Ashish Ranjan
 
  Re: Write the program form Armstrong no in c++?
Answer
# 7
#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 ?    15 Yes 5 No
Roshan Patel
 
  Re: Write the program form Armstrong no in c++?
Answer
# 8
#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
Ramesh
 
  Re: Write the program form Armstrong no in c++?
Answer
# 9
#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
Sarang Deshpande
 
  Re: Write the program form Armstrong no in c++?
Answer
# 10
#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
Astitva Srivastava
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
Write the program for fibonacci in c++? Wipro 18
Write a function which takes a character array as input and reverses it in place. Lehman-Brothers 2
write a c++ program that gives output 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 using looping statement   2
Write a corrected statement in c++ so that the statement will work properly. x =+ 7;   2
Please post the model question paper of hal?   2
what is polymorphism? Accenture 14
Copy Linked List using recursive function? Persistent 2
why can't we declare data member of class auto register or extern   1
can anybody please tell me how to write a program in c++,without using semicolon(;) NIIT 6
When a function is made inline. Write the situation where inline functions may not work.   2
if int1 has the value 12, int has the value 18, and int3 has the value 21, what is the result: int1 < int2 && int2 < int 3   3
How do you link a C++ program to C functions?   3
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com