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
How can I pad a string to a known length?
What is static memory allocation? Explain
What is difference between union and structure in c?
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?
Explain what is a static function?
Can you please explain the difference between exit() and _exit() function?
How can I swap two values without using a temporary?
What is pre-emptive data structure and explain it with example?
How many bytes are occupied by near, far and huge pointers (dos)?
What are c header files?
What are loops in c?
Explain why c is faster than c++?
Which is more efficient, a switch statement or an if else chain?
What does stand for?
What is difference between structure and union in c programming?