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
What are type modifiers in c?
What is the function of this pointer?
What are the advantages of Macro over function?
What does c in a circle mean?
What are void pointers in c?
Linked lists -- can you tell me how to check whether a linked list is circular?
What are the differences between Structures and Arrays?
What is a lookup table in c?
Can math operations be performed on a void pointer?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
What is a class c rental property?
Can a void pointer point to a function?
What is printf () in c?
How can you find out how much memory is available?
What are valid signatures for the Main function?