Sorry for the many questions. I am studying for my final in a week and i am going over my midterm.
So on the midterm the question was what would be the output if user input was 10. I put 11 cause i thought 100 divided by 10 was 10 and then plus plus is 11. But the answer is 3 and i have no clue how.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main()
{
int number;
int counter=0;
cout<<"Enter an integer\n";
cin>>number;
while (number>0)
{number=number/10;
counter++;}
cout<< "The counter for your number is " << counter<< endl;
return 0;
}