In This program user ask to find out the number is Armstrong or not. “A number is Armstrong if the sum of cubes of individual digits of a number is equal to the number itself”. User declares required variables for this operation. User uses a temp variable that will use to store the value for temporary time period. Declaring while condition while (num>0) user ask to cub=num%10, num=num/10, sum=sum+ (cub*cub*cub).
Then a if-else condition if(temp==sum) then the number is Armstrong else it will not. And after creating all instance in the end display result on the screen as output.
This is C program to Check out the Number is Armstrong or not.
- Declaring the variables.
- Using while condition along with control statements.
- Display result on the Screen.
Here is C source code for checking out the number is Armstrong or not. The output of this program shown below.
printf("Enter a Number : ");
printf("Number is Armstrong");
printf("Number is not Armstrong");