Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can the sizeof operator be used to tell the size of an array passed to a function?

1076


differentiate built-in functions and user – defined functions.

1054


What are the restrictions of a modulus operator?

1084


When should a type cast not be used?

1020


What does c mean in standard form?

1133


Where is volatile variable stored?

1045


What is the difference between memcpy and memmove?

988


How is a macro different from a function?

1136


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1950


Is that possible to store 32768 in an int data type variable?

1046


What is the best organizational structure?

1079


What is conio h in c?

1013


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

1033


What is the difference between union and structure in c?

1111


How to throw some light on the b tree?

1041