#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
void main()
{
long num1,num2=0,mcount=0, nums;
char str1[35], strc;
clrscr();
printf("Enter a number : ");
scanf("%ld",&num1);
ltoa(num1,str1,10);
while (mcount <= (strlen(str1)-1))
{
strc = str1[mcount];
nums = atoi(&strc);
num2 = num2+pow(nums,3);
mcount = mcount+1;
}
if (num1 == num2)
{
printf("Amstrong Number : %ld",num2);
}
else
{
printf("Not a Amstrong Number.");
}
getch();
}
#include <stdlib.h>
#include <string.h>
#include <math.h>
void main()
{
long num1,num2=0,mcount=0, nums;
char str1[35], strc;
clrscr();
printf("Enter a number : ");
scanf("%ld",&num1);
ltoa(num1,str1,10);
while (mcount <= (strlen(str1)-1))
{
strc = str1[mcount];
nums = atoi(&strc);
num2 = num2+pow(nums,3);
mcount = mcount+1;
}
if (num1 == num2)
{
printf("Amstrong Number : %ld",num2);
}
else
{
printf("Not a Amstrong Number.");
}
getch();
}
0 comments:
Post a Comment