Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to check whether a given integer is a strong
number or not?
[Hint:
145=1!+4!+5!
=1+24+120
=145]

Answer Posted / paul zarkovich

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

using namespace std;

main()
{
int n,fact=1,sum=0,digit=0;

printf("Enter a number : ");
scanf("%d",&n);

int temp=n,a=n;

if(temp<10)
{
for(int i=temp;i>0;i--)
fact*=i;

if(n==fact)
printf("It is a strong no. ");
else
printf("It is not a strong no. ");
}

else
{
while(temp>10)
{
digit=temp%10;

temp/=10;

for(int i=digit;i>0;i--)
fact*=i;

sum+=fact;
fact=1;
}
for(int i=temp;i>0;i--)
fact*=i;

sum+=fact;
if(sum==n)
printf("It is a strong no. ");
else
printf("It is not a strong no. ");

}

getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What should malloc(0) do?

1115


How many identifiers are there in c?

1018


an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational

1313


What is the difference between near, far and huge pointers?

1093


Explain c preprocessor?

1110


What is #include stdlib h?

1103


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

1042


What is the default value of local and global variables in c?

1038


what is the difference between 123 and 0123 in c?

1201


What is class and object in c?

1116


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

2057


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

1061


What are header files in c?

1076


How can you restore a redirected standard stream?

1119


Which function in C can be used to append a string to another string?

1217