//armstrong number
//sum of each digit of the cubes equal to given number
#include<stdio.h>
#include<conio.h>
int arm(int n)
{
int sum=0,a,rem;
a=n;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
}
return(a==sum);
}
void main()
{
int n,arm(int);
clrscr();
printf("etner n value\n");
scanf("%d",&n);
if(arm(n))
printf("armstrong number\n");
else
printf("not a armstrong number\n");
getch();
}
//sum of each digit of the cubes equal to given number
#include<stdio.h>
#include<conio.h>
int arm(int n)
{
int sum=0,a,rem;
a=n;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
}
return(a==sum);
}
void main()
{
int n,arm(int);
clrscr();
printf("etner n value\n");
scanf("%d",&n);
if(arm(n))
printf("armstrong number\n");
else
printf("not a armstrong number\n");
getch();
}
c programs
(To execute this flow chart you should install raptor
software)
Download
raptor software to draw and execute flow chart
No comments:
Post a Comment