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 you increase the allowable number of simultaneously open files?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
What do you mean by Recursion Function?
a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor
What is default value of global variable in c?
What are pointers? What are different types of pointers?
Which programming language is best for getting job 2020?
What's the best way of making my program efficient?
What is %d called in c?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
What is strcmp in c?
What is data structure in c and its types?
What is the best way to comment out a section of code that contains comments?
Explain the bubble sort algorithm.
What is the scope of an external variable in c?