This is the program to check whether given number is Armstrong number or not
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main(int argc, char *argv[])
{
int num,n,sum=0;
num=atoi(argv[1]);
if(argc==2 && num>0 && num<=INT_MAX)
{ n=num;
while(num>0)
{
sum+=(num%10)*(num%10)*(num%10);
num/=10;
}
if(sum==n)
printf("%d is an armstrong number",n);
else
printf("%d is not an armstrong number",n);
return 0;
}
else
return 1;
}
Here i gave an input
-12345678969
expected output
Command exited with non-zero status 1
but it shows
539222919 is not an armstrong number