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

Answers were Sorted based on User's Feedback



Given a number N, product(N) is the product of the digits of N. We can then form a sequence N, prod..

Answer / vivekamr91

#include<stdio.h>
int main()
{
int s,sum;
long num;
printf("enter the no:");
scanf("%ld",&num);
sum=num;
while(sum>10)
{
sum=0;
while(num!=0)
{
s=num%10;
sum=sum+s;
num=num/10;
}
num=sum;
}
printf("the single digit sum is :%d",sum);
return 0;
}

Is This Answer Correct ?    2 Yes 1 No

Given a number N, product(N) is the product of the digits of N. We can then form a sequence N, prod..

Answer / 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

More C Interview Questions

Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

0 Answers  


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

0 Answers   Amazon,


to find the program of matrix multiplication using arrays

6 Answers   Bhel,


Once I have used freopen, how can I get the original stdout (or stdin) back?

0 Answers  


what is the flow of execution in cprogram? ex:printf();,scanf();

2 Answers  


how does the for loop work actually..suppose for the following program how it ll work plz explain to me for(i=5;i>=0;i--) prinf(i--);

19 Answers   RMSI,


Difference between MAC vs. IP Addressing

0 Answers  


What does a pointer variable always consist of?

0 Answers  


What is #define?

0 Answers  


What are function pointers? Provide an example.

1 Answers  


How can I access a memory located at certain address?

2 Answers   CSC,


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

0 Answers  


Categories