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 / vetrivel
#include<stdio.h>
int fact(int r)
{
if(r=0 || r=1)
return 1;
else
return(r*fact(r-1);
}
void main()
{
int a,n,rem,sum=0
printf("Enter the number\n");
scanf("%d",&n);
a=n;
while(n!=0)
{
rem=n%10;
sum=sum+fact(rem);
n=n/10;
}
if(sum==a)
printf("%d is a strong number",a);
else
printf("%d is not a strong number",a);
}
| Is This Answer Correct ? | 8 Yes | 5 No |
Post New Answer View All Answers
Are comments included during the compilation stage and placed in the EXE file as well?
Write a c program to demonstrate character and string constants?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
What are the advantages and disadvantages of a heap?
Can we add pointers together?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
What is a char in c?
Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
How can I run c program?
What is time null in c?
What is an operator?
How can you increase the size of a statically allocated array?
What is c basic?