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 number is Peterson or not.

Answer Posted / lalabs

void find_peterson_num ( int num )
{
int sum;
int fact, i;
int temp = num;

do
{
for ( i = 1, fact = 1; i <= (temp % 10); i++)
{
fact *= i;
}

sum += fact;
temp /= 10;

} while ( temp > 0);

if ( sum == temp )
{
printf ( "%d is Perterson number of %d\n", num, sum );
}

printf ( "%d is NOT Perterson number of %d\n", num, sum );
}

Is This Answer Correct ?    8 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I pad a string to a known length?

969


What is static memory allocation? Explain

1033


What is difference between union and structure in c?

1070


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

1170


Explain what is a static function?

1047


Can you please explain the difference between exit() and _exit() function?

993


How can I swap two values without using a temporary?

1060


What is pre-emptive data structure and explain it with example?

3656


How many bytes are occupied by near, far and huge pointers (dos)?

1116


What are c header files?

951


What are loops in c?

953


Explain why c is faster than c++?

1005


Which is more efficient, a switch statement or an if else chain?

969


What does stand for?

1045


What is difference between structure and union in c programming?

1017