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
what are the facialities provided by you after the selection of the student.
What are the types of type qualifiers in c?
what is bit rate & baud rate? plz give wave forms
What is the 'named constructor idiom'?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
Stimulate calculator using Switch-case-default statement for two numbers
What does %c do in c?
What is the use of typedef in structure in c?
Explain the concept and use of type void.
What does == mean in texting?
Explain how are 16- and 32-bit numbers stored?
Do character constants represent numerical values?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What does != Mean in c?