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 c preprocessors?
Write a program to print “hello world” without using semicolon?
Can a local variable be volatile in c?
How does #define work?
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
What is meant by high-order and low-order bytes?
Is c is a low level language?
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
What is an array in c?
What is C language ?
What are reserved words with a programming language?
How do you define a function?
Where is c used?
Explain how can I convert a number to a string?
What is the use of c language in real life?