#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int i,j,n,num=0;
clrscr();
cout<<"\nenter the number ";
cin>>n;
int m=n;
while((m%10!=0)||(m/10!=0))
{
num=num+pow((m%10),3);
// cout<<"\n"<<num;
// getch();
m=m/10;
}
cout<<" "<<num;
if(num==n)
{
cout<<"\nthe number is armstrong ";
}
else
{
cout<<"\nthe number is not armstrong ";
}
getch();
}
OUTPUT:
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int i,j,n,num=0;
clrscr();
cout<<"\nenter the number ";
cin>>n;
int m=n;
while((m%10!=0)||(m/10!=0))
{
num=num+pow((m%10),3);
// cout<<"\n"<<num;
// getch();
m=m/10;
}
cout<<" "<<num;
if(num==n)
{
cout<<"\nthe number is armstrong ";
}
else
{
cout<<"\nthe number is not armstrong ";
}
getch();
}
OUTPUT:
No comments:
Post a Comment