# Answer to Question #22112 in C++ for Elgun Cebrayilov

Question #22112

The positive integer number N is given. We subtract from this number the sum of its digits. From the received number we soon subtract the sum of its digits and so on. This operation continues until the number is positive. How many times this operation will be repeated?

Expert's answer

#include <iostream>

#include <vector>

#include <fstream>

#include <time.h>

#include <string>

using namespace std;

int main(){

int number;

cout<<"Enter number";

cin>>number;

int i;

for (i = 0; 1 ; i++){

char& a[100];

itoa(number,a,10);

int b = 0;

for (int j = 0 ; a[j] != '\0' ; j++){

b += int(a[j]) - 48;

}

number -= b;

}

system("pause");

return 0;

}

#include <vector>

#include <fstream>

#include <time.h>

#include <string>

using namespace std;

int main(){

int number;

cout<<"Enter number";

cin>>number;

int i;

for (i = 0; 1 ; i++){

char& a[100];

itoa(number,a,10);

int b = 0;

for (int j = 0 ; a[j] != '\0' ; j++){

b += int(a[j]) - 48;

}

number -= b;

}

system("pause");

return 0;

}

## Comments

## Leave a comment