Sorry. I had to delete the older version, for it was written in C++, while the questioner had asked one in C. So here it is. In fact, I will give the questioner a bonus, it will print not only Armstrong numbers but all Narcissistic numbers (here the power to which the individual digits should be raised before being added to each other can be any integer. Clearly Armstrong numbers form a subset of these numbers, with the power equal to three), and that too not only upto 10000, but upto the maximum number a C compiler can process. Enjoy!
#include
#include
main()
{
int m=1,b;
int a[200],i,j,k,l;
while (m<=2147483647)
{
b=m;
i=0;
while (b>=1)
{
a[i]=(b%10);
b=floor(b/10);
++i;
}
for (j=1;j<=9;++j)
{
k=0;
for (l=(i-1);l>=0;--l)
k+= pow(a[l],j);
if (k==m)
goto sexy;
}
goto label;
sexy: printf("%d (raise every digit to power of %d)\n",m,j);
label: ++m;
}
}
#include
#include
using namespace std;
int main(void)
{
int upper,lower;
cout<<"Enter the limits"<
for(int i=lower;i<=upper;i++)
{
int temp=i;
int sum=0;
int count=0;
while(temp>0)
{
temp=temp/10;
count++;
}
temp=i;
while(temp>0)
{
n=temp%10;
temp=temp/10;
int cal=pow(n,count);
sum=sum+cal;
}
if(sum==i)
cout<<"Armstrong Numbers are"<
return 0;
}
//This program checks whether or not a number is palindrome #include
void main()
{
int rem,sum=0,n,num;
clrscr();
printf("Enter a number\n");
scanf("%d",&num);
n=num;
while(n!=0)
{
rem=n%10;
n=n/10;
sum+=rem*rem*rem;
}
if(sum==num)
printf("%d is an armstrong",num);
else
printf("%d is not armstrong",num);
getch();
}
To write a C++ program to display the student details using class and array of object.
You do nothing! A sequence of numbers will contain no X and so nothing needs doing!
ring me and ill explain - 086 22222222222222227 ring me
program to extract a given word from a file
Poor Boy. We do not do your homework here.
write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html
To write a C++ program to display the student details using class and array of object.
You do nothing! A sequence of numbers will contain no X and so nothing needs doing!
Reference: cprogramming-bd.com/c_page4.aspx#ODD%20 Numbers
ring me and ill explain - 086 22222222222222227 ring me
for(int i = 1; i < 100; i+=2) { System.out.println(i); }
Count all the given numbers then count all the numbers of a given value. Divide one by the other and multiply by 100. For instance, if there are 50 numbers in total and 5 of them have the value 42, then the percentage of numbers with the value 42 is 5 / 50 * 100 = 10%.
program to extract a given word from a file
It is your face
Without knowing what the numbers are, I would suggest taking the mean of the given numbers.
Poor Boy. We do not do your homework here.
write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)