Write
a program to find 1st three (3) Armstrong Number starting from 1
Hints:
The
condition for Armstrong number is,
Sum of the cubes of its digits must equal to the number itself.
For example, 407 is given as input.
4 * 4 * 4 + 0 * 0 * 0 + 7 * 7 * 7 = 407 is an Armstrong number.
#include
উত্তরমুছুনusing namespace std;
int main()
{
int i,sum=0,rem,temp;
cout<<"First three armstrong numbre is:"<<endl;
for(i=1;i<=370;i++)
{
temp=i;
while(temp!=0)
{
rem=(temp%10);
sum+=rem*rem*rem;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
#include
উত্তরমুছুনusing namespace std;
int main()
{
int i,sum=0,rem,temp;
cout<<"First three armstrong numbre is:"<<endl;
for(i=1;i<=370;i++)
{
temp=i;
while(temp!=0)
{
rem=(temp%10);
sum+=rem*rem*rem;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
/*Amena Akter Anni
উত্তরমুছুনID:30934
Betch:47th*/
#include
using namespace std;
void armstrong(int n)
{
int j,temp,res=0,sum=0;
temp=n;
while(temp>0){
j=temp%10;
res=j*j*j;
temp/=10;
sum+=res;
}
if(sum==n)
cout<<"The armstrong number is:"<>i;
armstrong(i);
}
/*Amena Akter Anni
উত্তরমুছুনID:30934
Betch:47th*/
#include
using namespace std;
void armstrong(int n)
{
int j,temp,res=0,sum=0;
temp=n;
while(temp>0){
j=temp%10;
res=j*j*j;
temp/=10;
sum+=res;
}
if(sum==n)
cout<<"The armstrong number is:"<>i;
armstrong(i);
}
/*Amena Akter Anni
উত্তরমুছুনID:30934
Betch:47th*/
#include
using namespace std;
void armstrong(int n)
{
int j,temp,res=0,sum=0;
temp=n;
while(temp>0){
j=temp%10;
res=j*j*j;
temp/=10;
sum+=res;
}
if(sum==n)
cout<<"The armstrong number is:"<>i;
armstrong(i);
}
/*Amena Akter Anni
উত্তরমুছুনID:30934
Betch:47th*/
#include
using namespace std;
void armstrong(int n)
{
int j,temp,res=0,sum=0;
temp=n;
while(temp>0){
j=temp%10;
res=j*j*j;
temp/=10;
sum+=res;
}
if(sum==n)
cout<<"The armstrong number is:"<>i;
armstrong(i);
}
/*Amena Akter Anni
উত্তরমুছুনID:30934
Betch:47th*/
#include
using namespace std;
void armstrong(int n)
{
int j,temp,res=0,sum=0;
temp=n;
while(temp>0){
j=temp%10;
res=j*j*j;
temp/=10;
sum+=res;
}
if(sum==n)
cout<<"The armstrong number is:"<>i;
armstrong(i);
}
/*Amena Akter Anni
উত্তরমুছুনID:30934
Betch:47th*/
#include
using namespace std;
void armstrong(int n)
{
int j,temp,res=0,sum=0;
temp=n;
while(temp>0){
j=temp%10;
res=j*j*j;
temp/=10;
sum+=res;
}
if(sum==n)
cout<<"The armstrong number is:"<>i;
armstrong(i);
}
//Batch:46th , id:201420262
উত্তরমুছুন#include
using namespace std;
int armstrong(int sum=0)
{
int i, rem, temp;
for(i=1;i<=370;i++)
{
temp=i;
while(temp!=0)
{
rem=(temp%10);
sum+=rem*rem*rem;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
}
int main()
{
cout<<"first three armstrong number is:"<<endl;
armstrong( );
return 0;
}
mehrin
উত্তরমুছুনid-201430310
#include
using namespace std;
int armstrong_number(int num)
{
int i,sum=0,rem,temp;
cout<<"Armstrong number are: "<<endl;
for(i=1;i<=1370;i++)
{
temp=i;
while(temp!=0)
{
rem =(temp%10);
sum+= rem*rem*rem;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
int main()
{
int num;
armstrong_number(num);
return 0;
}
#include
উত্তরমুছুনusing namespace std;
int armstrong_check(int a)
{
int i,sum=0,r,temp;
cout<<"Armstrong number are: "<<endl;
for(i=1;i<=5000;i++)
{
temp=i;
while(temp!=0)
{
r=(temp%10);
sum+= r*r*r;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
int main()
{
int a;
armstrong_check(a);
return 0;
}
sohagi akter sumi
উত্তরমুছুন201420134 betch 46th
#include
using namespace std;
int armstrong_num(int r)
{
int i,sum=0,m,n;
cout<<"Armstrong number are: "<<endl;
for(i=1;i<=2000;i++)
{
n=i;
while(n!=0)
{
m=(n%10);
sum+= m*m*m;
n/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
int main()
{
int r;
armstrong_num(r);
return 0;
}
/*
উত্তরমুছুনBashir Fardoush
ID: 201430385
Betsh; 47th
Write a program to find 1st three (3) Armstrong Number starting from 1
*/
#include
using namespace std;
int armstrong(int startv)
{
cout<<"First 3 Armstrong numbers are: ";
int i,num=0,temp=0,sum=0,count=0;
for(i=startv; ;i++)
{
num=i;
while(num!=0)
{
temp=num%10;
sum+=temp*temp*temp;
num=num/10;
}
if(sum==i)
{
cout<=3)break;
}
cout<<endl;
}
int main(){
int inv;
inv=1;
armstrong(inv);
return 0;
}
//Batch:46th , id:201420262
উত্তরমুছুন#include
using namespace std;
int armstrong(int sum=0)
{
int i, rem, temp;
for(i=1;i<=370;i++)
{
temp=i;
while(temp!=0)
{
rem=(temp%10);
sum+=rem*rem*rem;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
}
int main()
{
cout<<"first three armstrong number is:"<<endl;
armstrong( );
return 0;
}
RIPON
উত্তরমুছুনID:734
Betch:47
//Write a program to find 1st three (3) Armstrong Number starting from 1
#include
using namespace std;
int armstrong_number(int n)
{
int i,t,m,h,sum=0;
cout<<"Armstrong number"<>n;
for(i=1;i<=h;i++)
{
t=i;
while(t!=0)
{
m=t%10;
t/=10;
sum+=m*m*m;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
int main()
{
int n;
armstrong_number(n);
return 0;
}
ID-201210433
উত্তরমুছুনBatch 39th
#include
using namespace std;
int main()
{
int i,sum=0,rem,temp;
cout<<"All Armstrong number is:"<<endl;
for(i=0;i<=1000;i++)
{
temp=i;
while(temp!=0)
{
rem=(temp%10);
sum+=rem*rem*rem;
temp/=10;
}
if(i==sum)
{
cout<<i<<endl;
}
sum=0;
}
return 0;
}
#include
উত্তরমুছুনusing namespace std;
int armstrong(int inp);
int main()
{
int inp,last;
cout<<"Enter the range: ";
cin>>inp;
last=armstrong(inp);
cout<<"The last armstrong number is :"<<last;
return 0;
}
int armstrong(int inp)
{
int num,r,sum,temp,last;
for(num=1;num<=inp;num++)
{
temp=num;
sum = 0;
while(temp!=0)
{
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
{
cout<<num<<" ";
last=num;
}
}
return last;
}