So far, this is where I'm at:
void divideme()
static int count=0; //initalised a variable which I'll be returning the value of.
int n;
cin>>n;//taken input of variable which I want to divide by another number (say 10 in this case)
int &rem=n;//created a reference variable which stores the value of n.
if (rem>=10) {
while (rem>=10) {//how do we count how many times it divides by 10?
rem=rem%10;
count++;
}
}
return count;
the problem with this program is that the 'count' variable is incremented only once, since the program divides the 'rem' variable.
To calculate how many times 10 goes into a number (n). (Corrected question)
Aucun commentaire:
Enregistrer un commentaire