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

What are c preprocessors?

670


Write a program to print “hello world” without using semicolon?

667


Can a local variable be volatile in c?

571


How does #define work?

642


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

660






What is meant by high-order and low-order bytes?

644


Is c is a low level language?

555


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

636


What is an array in c?

589


What is C language ?

1522


What are reserved words with a programming language?

593


How do you define a function?

577


Where is c used?

644


Explain how can I convert a number to a string?

636


What is the use of c language in real life?

525