#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
clrscr();
int num,r,sum=0,temp;
textcolor(GREEN);
cprintf("Enter The number=");
scanf("%d",&num);
temp=num;
while(num!=0)
{
int r=num%10 ;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
{
textcolor(RED);
cprintf("%d Armstrong number" ,temp);
}
else
{
cprintf("%d not Armstrong number",temp);
}
getch();
}
output
#include<conio.h>
#include<graphics.h>
void main()
{
clrscr();
int num,r,sum=0,temp;
textcolor(GREEN);
cprintf("Enter The number=");
scanf("%d",&num);
temp=num;
while(num!=0)
{
int r=num%10 ;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
{
textcolor(RED);
cprintf("%d Armstrong number" ,temp);
}
else
{
cprintf("%d not Armstrong number",temp);
}
getch();
}
output
No comments:
Post a Comment