Given a number N, product(N) is the product of the digits of
N. We can then form a sequence N, product(N),
product(product(N))… For example, using 99, we get the
sequence 99, 99 = 81, 81 = 8.
Input Format:
A single integer N
Output Format:
A single integer which is the number of steps after which a
single digit number occurs in the sequence.
Sample Test Cases:
Input #00:
99
Output #00:
2
Explanation:
Step - 1 : 9 * 9 = 81
Step - 2 : 8 * 1 = 8
There are 2 steps to get to this single digit number.
Input #01:
1137638147
Answer Posted / tuhin banerjee
#include<stdio.h>
int main()
{
int s,mul;
long num;
int count =0;
printf("enter the no:");
scanf("%ld",&num);
mul=num;
while(mul>10)
{
mul=1;
while(num!=0)
{
s=num%10;
mul=mul*s;
num=num/10;
}
num=mul;
count++;
}
printf("the single digit sum is :%d",mul);
printf("the single digit answer is :%d",count);
return 0;
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Why static variable is used in c?
What are data structures in c and how to use them?
What is the size of enum in bytes?
What are pointers?
Explain what math functions are available for integers? For floating point?
What are the different types of control structures in programming?
Why do we need volatile in c?
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Why is not a pointer null after calling free?
What does the characters “r” and “w” mean when writing programs that will make use of files?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
define string ?
Does free set pointer to null?
Can you apply link and association interchangeably?