Tuesday, 27 December 2016

armstrong number in c

#include<stdio.h>
int main()
{
     int num, sum = 0;
         

    printf("Please enter a number: ");      
    scanf("%d",&num);

     for (int i = num; i > 0;)
            {
                sum += (i % 10) * (i % 10) * (i % 10);
                i = i / 10;

            }
 if ( sum==num)
        printf("%d is an armstrong number.",num);
    else
        printf("%d is not an armstrong number.",num);

    return 0;
}

No comments:

Post a Comment

How to Setup SLA in CE module

Setting Up SLA (Service Level Agreements) in Dynamics 365 Customer Engagement (CE) A Service Level Agreement (SLA) in Dynamics 365 CE (Cust...