Q.) Write a C program to check whether the number is ARMSTRONG NUMBER or NOT .
Sol)
#include<stdio.h>
#include<conio.h>
int main()
{
int num,r,sum=0,temp ;
printf("Enter a number: ") ;
scanf("%d",&num) ;
scanf("%d",&num) ;
temp=num ;
while(num!=0)
{
r=num%10;
num=num/10;
sum=sum+(r*r*r) ;
}
if(sum==temp)
print("%d is an ARMSTRONG NUMBER",temp) ;
else
printf("%d is not an ARMSTRONG NUMBER", temp) ;
return 0 ;
}
No comments:
Post a Comment