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 / amolraje lendave
#include<iostream.h>
#include<conio.h>
int main()
{
int j,t,n,r,s=0,i,f=1;
clrscr();
for(j=3;j<=1000;j++)
{
s=0;
n=j;
while(n>0)
{
f=1;
r=n%10;
for(i=1;i<=r;i++)
{
f=f*i;
}
s=s+f;
n=n/10;
}
if(j==s)
{
cout<<j<<endl;
}
else
continue;
}
getch();
return 0;
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Why header file is used in c?
Explain how can type-insensitive macros be created?
How do you convert strings to numbers in C?
What's a good way to check for "close enough" floating-point equality?
What does the characters “r” and “w” mean when writing programs that will make use of files?
Can you subtract pointers from each other? Why would you?
I have seen function declarations that look like this
What is the best organizational structure?
What is a char c?
Explain how do you determine the length of a string value that was stored in a variable?
Can we change the value of #define in c?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What does int main () mean?
how to construct a simulator keeping the logical boolean gates in c
Explain how can I avoid the abort, retry, fail messages?