write a program to check whether a number is Peterson or not.
Answer Posted / rama krishna sidhartha
Peterson number means sum of factorials of digits of a given
number.
//code :
#include<stdio.h>
#include<conio.h>
void main()
{
int n,c,s=0,m,i,f=1;
clrscr();
printf("\n ENTER A VALUE : ");
scanf("%d",&n);
m=n;
while(n>o)
{
c=n%10;
for(i=0;i<c;i++)
f=f*i;
s=s+f;
f=1;
n=n/10;
}
if(s==m)
printf("\n THE ENTERED NUMBER IS PETERSON
NUMBER.");
else
printf("\n THE ENTERED NUMBER IS NOT A
PETERSON NUMBER.");
getch();
}
| Is This Answer Correct ? | 56 Yes | 22 No |
Post New Answer View All Answers
How do you print an address?
What are enumerated types?
Describe the steps to insert data into a singly linked list.
Write the control statements in C language
What are 'near' and 'far' pointers?
Is a house a mass structure?
Write programs for String Reversal & Palindrome check
What is the size of array float a(10)?
When should I declare a function?
Hai what is the different types of versions and their differences
int far *near * p; means
Explain what is output redirection?
Explain what are reserved words?
What does != Mean in c?
What is wrong with this program statement?