By Dilkash
from manuu
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int rem,sum=0,a,len=0,num,num1,rem1;
clrscr();
printf("Enter Any Number\n");
scanf("%ld",&a);
num=a;
num1=num;
while(a!=0)
{
rem=a%10;
len=len+1;
a=a/10;
}
while(num!=0)
{
rem1=num%10;
sum=sum+(pow(rem1,len));
num=num/10;
}
if(num1==sum)
printf("\n%ld is ARMSTRONG\n",num1);
else
printf("\n%ld is Not ARMSTRONG\n",num1);
getch();
}
//MANUU POLYTECHNIC BANGALORE
#include <iostream>
#include <math.h> // for std::pow()
unsigned int get_length(unsigned int num,const unsigned int base=10)
{
unsigned int len=1;
while(num && (num/=base))
++len;
return( len );
}
bool is_armstrong(const unsigned int num,const unsigned int base=10)
{
unsigned int len=get_length(num,base);
unsigned int sum=0;
unsigned int tmp=num;
while(tmp)
{
sum+=(unsigned int)std::pow((double)(tmp%base),(double)len);
tmp/=base;
}
return(num==sum);
}
int main()
{
std::cout << "Armstrong series (base 10):";
for(unsigned int num=0; num<=0xffffffff; ++num)
if(is_armstrong(num))
std::cout << " " << num;
std::cout << std::endl;
return(0);
}
how to write a program that counts automorphic number from 1 to 999
Divide it by 1000.
Don't write, it is already written, google for 'cpp'.
there is no solution of this problem...........that's it..........
Its limited only by available memory.
By learning how to program on C+.
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.
how to write a program that counts automorphic number from 1 to 999
Divide it by 1000.
No.
Don't write, it is already written, google for 'cpp'.
there is no solution of this problem...........that's it..........
Its limited only by available memory.
Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.
printf ("x")
int x= 1; int y= 2;
Yes, you can program games with C++.