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 variables are declared in c?
How can I generate floating-point random numbers?
What is a pointer value and address in c?
#include
Can a variable be both constant and volatile?
What is variable declaration and definition in c?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
What is a union?
Explain what is the difference between null and nul?
Explain what is output redirection?
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel
Why is it that not all header files are declared in every C program?
What is string concatenation in c?
What are loops c?
What are pointers? Why are they used?