Sunday 23 June 2013

Q. Write a program to find the given number is strong or not?

#include<stdio.h>
#include<conio.h>

void main()
{
    unsigned int n,x,l,m,fact,a=1,ans=0;
    clrscr();
    printf("\nEnter Number:");
    scanf("%d",&n);
    x=n;
    while(n> 9)
    {
        fact=1;
        l=n%10;
        n=(n-l)/10;
        m=l;
        do
        {
            fact=fact*m;
            m--;
        }
        while(m!= 0);
        ans=ans+fact;
    }
    do
    {
        a=a*n;
        n--;
    }while(n!=0);
    ans=ans+a;
    printf("\nANSWER: %d",ans);
    if(ans==x)
        printf("\nThe number is Strong");
    else
        printf("\nThe Number is not strong");
getch();

No comments:

Post a Comment

Hello Friends...! Lets share Your Views,Ideas,Comments here....!!

Popular Posts