Command Line Program for Armstrong Number

C program to find Armstrong number using Command line arguments

A number is called Armstrong number if the Sum of the cubes of its digits is equal to the number itself.

The following is a C program to check whether the given number is Armstrong number or not using command line arguments.

Note: Please go through Command Line Arguments Post before preparing for these questions. The theory there  for TCS command line Program will help you in better understanding .

#include<stdio.h>
int main(int argc, char * argv[])
{
int num,temp,arms=0,rem;
if (argc!= 2)
{
 printf("Enter the number:\n");
 scanf("%d",&num);
}
else
{
 num = atoi(argv[1]);
}
 temp=num;
while(num>0)
{
 rem=num%10;
 arms=arms+rem*rem*rem;
 num=num/10;
}
if(temp==arms)
{
 printf(" \n%d is an Armstrong number",temp);
}
else
{
 printf("\n%d is not an Armstrong number",temp);
}
return 0;
}