8. Write a program to find whether the number is Armstrong number.

 SOURCE CODE:


include <stdio.h>

int main()
{   int num,rem,res=0,real_num;

    printf("enter a number\n");
    scanf("%d",&num);

    real_num=num;
    while(real_num!=0){
    rem=real_num%10;
    res+=rem*rem*rem;
    real_num/=10;
    }
     if(num==res)
     { printf("%d is an armstrong number",num); }
     else
     printf("%d is not an armstrong number",num);

    return 0;
}


Comments

Popular posts from this blog

2. Basic salary of an employee is input through the keyboard. The DA is 25% of the basic salary while the HRA is 15% of the basic salary. Provident Fund is deducted at the rate of 10% of the gross salary (BS+DA+HRA). Write a program to calculate the Net Salary.

4. Write a program to find the largest of three numbers using nested if else