help with persistence code need to ask user for number

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#include <iostream>
using namespace std;
int Persistent(int value)
{

int counter = 0;

while (value > 10)
{
int newvalue = 1;
int tmpvalue = value;


while (tmpvalue > 0)
{	
// I get the last digit
int tmp = tmpvalue % 10;
newvalue *= tmp;
// last digit is cut
tmpvalue /= 10;
}
value = newvalue;
cout << "element: " << value << endl;
counter++;	
}

return counter;

}


int main()
{
    
    
    int originalNumber(715);
    
    cout << "Please enter a non negative number" << endl;
    cin >>  originalNumber >>
    cout << originalNumber << endl;
	
	
	cout << " number of element: " << Persistent(715);
	return 0;
	

	return 0;

}

Look closely @ line 40...

cin >> originalNumber; not >>
ok still not working for the user to input 715
closed account (48T7M4Gy)
Ever growing team of volunteers working on this project for OP all over the place

http://www.cplusplus.com/forum/general/177311/
http://www.cplusplus.com/forum/beginner/177290/
http://www.cplusplus.com/forum/beginner/177321/
http://www.cplusplus.com/forum/beginner/177330/
http://www.cplusplus.com/forum/beginner/177327/
Topic archived. No new replies allowed.