Program in c++ language for ARMSTRONG NUMBER...
DESCRIPTION:- This program will tell you that entered number is an armstroong number or not.
Simple funda is used that .i Just take a function name void cal(int num,int check)
and use some method inside it.
OUTPUT :
SOURCE CODE:-
#include<iostream>
#include<conio.h>
using namespace std;
void cal(int num,int check)
{
static int sum=0;
if(num!=0)
{
int x=num%10;
int cub=x*x*x;
sum=sum+cub;
num=num/10;
cal(num,check);
}
else
if(sum==check)
{
cout<<"\nYes it is an armstrong number:";
}
else
{
cout<<"\nNOt an armstrong number:";
}
}
int main()
{
int num;
cout<<"\nEnter the number:";
cin>>num;
cal(num,num);
getch();
}
/*
THANKU.
DESCRIPTION:- This program will tell you that entered number is an armstroong number or not.
Simple funda is used that .i Just take a function name void cal(int num,int check)
and use some method inside it.
OUTPUT :
SOURCE CODE:-
#include<iostream>
#include<conio.h>
using namespace std;
void cal(int num,int check)
{
static int sum=0;
if(num!=0)
{
int x=num%10;
int cub=x*x*x;
sum=sum+cub;
num=num/10;
cal(num,check);
}
else
if(sum==check)
{
cout<<"\nYes it is an armstrong number:";
}
else
{
cout<<"\nNOt an armstrong number:";
}
}
int main()
{
int num;
cout<<"\nEnter the number:";
cin>>num;
cal(num,num);
getch();
}
/*
THANKU.
0 comments:
Post a Comment