Tuesday, November 1, 2011

Find whether a given number is Strong or not

Write a program in C to find whether a given number is Strong or not


Program:


#include<stdio.h>
#include<conio.h>
void main()
{
int sof=0,n,dn,ctr,prod,rem;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
dn=n;
while(n!=0)
{
prod=1,ctr=1;
rem=n%10;
while(ctr<=rem)
{
prod=prod*ctr;
ctr=ctr+1;
}
sof=sof+prod;
n=n/10;
}
if(sof==dn)
{
printf("The number entered is strong number");
}
else
{
printf("The number entered is not a strong number");
}
getch();
}

0 comments:

Post a Comment

About Me