Shopping In MUMBAI

Are you searching for Discounts, offers, sale in Mumbai ? You are in the right place. MUMBAI, a shopping haven, has no dearth of great discounts and sales. This blog features the best MUMBAI shopping offers, sale, discounts and deals and bargains CURRENTLY GOING on in Mumbai plus a few free things thrown in on top. Don't wait for it because once they are gone, they are gone. Hurry!..By clicking the "Like" button you will receive a daily update of discounts, sale, offers going on in Mumbai. LIKE IT.... SHARE IT...njoY.

Wednesday, December 31, 2008

C program to find if a given number is a strong number

Write a c program to find if a given number is a strong number.
( If the sum of the factorials of all digits of a number are equal to the
number, its called a strong number. )

#include
#include
void main()
{
int no,a[5],temp,i=0,j,fac[5]={1,1,1,1,1},k,sum;
clrscr();
printf("Enter any number(Less than (32767)");
scanf("%d",&no);
temp=no;
while(no!=0)
{
a[i]=no%10;
printf("%d\t",a[i]);
no=no/10;
i++;
}
printf("\n\n\n");
j=0;
do
{
for(k=1;k<=a[j];k++)
{

fac[j]=fac[j]*k;


}
printf("\na[j]=%d\tfac[j]=%d\n",a[j],fac[j]);
j++;
}while(jfor(j=0;j {
sum+=fac[j];
}
printf("\nsum=%d",sum);
if(sum==temp)
{
printf("\nThe number entered is a strong number");
}

else
{
printf("\nThe number entered is NOT a strong number");
}
getch();
}

/* Output
Enter any number(Less than (32767)1
1



a[j]=1 fac[j]=1

sum=4612
The number entered is NOT a strong number
*/

C program to find if a given number is a strong numberSocialTwist Tell-a-Friend

0 comments:

SUPPORT THIS BLOG