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

More C++ General Interview Questions

Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].

1 Answers  


Comment on local and global scope of a variable.

0 Answers  


Explain how to initialize a const member data.

0 Answers  


Differentiate between an external iterator and an internal iterator?

0 Answers  


what is difference between static and non-static variables

10 Answers  






Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list

0 Answers  


What is stl containers in c++?

0 Answers  


What are the types of array in c++?

0 Answers  


When to use Multiple Inheritance?

6 Answers  


What is the difference between the compiler and the preprocessor?

0 Answers  


what is multi-threading in C++?

0 Answers  


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

0 Answers  


Categories