Pages

Tuesday, 4 September 2012

WAP to check whether a number is an Armstrong Number or Not.

  •  WAP to check whether a num is an Armstrong Number or Not
#include <stdio.h>
#include <conio.h>
void main()
{
    int a,num,s=0,n;
    printf("enter a number");
    scanf("%d",&n);
    num=n;
    while(n>0)
    {
        a=n%10;
        s=s+a*a*a;
        n=n/10;
        }
        if(num==s)
        printf("%d is a Armstrong Number",num);
        else
        printf("%d is NOT a Armstrong Number",num);
    }

No comments:

Post a Comment