write a program to check whether a given integer is a strong
number or not?
[Hint:
145=1!+4!+5!
=1+24+120
=145]
Answer Posted / valli
int fact(int f)
{
if(f==1||f==0)
return 1;
else
return(f*fact(f-1));
}
main()
{
int n,i,j,s=0;
printf("enter the number");
scanf("%d",&n);
i=n;
while(n!=0)
{
j=n%10;
s=s+fact(j);
n=n/10;
}
if(i==s)
printf("strong number");
else
printf("not a strong number");
}
| Is This Answer Correct ? | 12 Yes | 8 No |
Post New Answer View All Answers
Is it possible to have a function as a parameter in another function?
What is null in c?
what are the 10 different models of writing an addition program in C language?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
Explain what are the different data types in c?
Why is c platform dependent?
What is the difference between procedural and declarative language?
Is that possible to add pointers to each other?
about c language
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
What is an array? What the different types of arrays in c?
What are the different types of control structures in programming?
What is the c language function prototype?
What is a pointer on a pointer in c programming language?