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
Is null valid for pointers to functions?
What is the easiest sorting method to use?
Write a program to check palindrome number in c programming?
write a c program in such a way that if we enter the today date the output should be next day's date.
Why functions are used in c?
What is the return type of sizeof?
What is the difference between struct and union in C?
When we use void main and int main?
List some of the dynamic data structures in C?
Give differences between - new and malloc() , delete and free() ?
What is an lvalue?
If errno contains a nonzero number, is there an error?
If fflush wont work, what can I use to flush input?
What is the purpose of 'register' keyword in c language?
How can I call fortran?