Welcome:
The question to the problem can
be found here:
Explanation:
1.Enter the integer as an character.
2.This will separate the biggest integer into smaller pieces.
3.Convert the pieces into integer and then add using a variable and store in the array s.
4.Convert the piece into character array
5.Continue until only 1 character is present.
6.Happy Coding.
Code:
#include<bits/stdc++.h>
using namespace std;
char s[100000];
int main(){
int cnt=0;
cin>>s;
while(s[1]){
cnt++;
int res =0;
for(int i=0;s[i];i++)
res+= s[i] - '0';
sprintf(s,"%d",res);
}
cout<<cnt;
return 0;}