im having trouble with the code trying to get it to do what i want it to do
basically i want to input a number for example 123456 and get back how many 7's are in the input number and also to print out that same number with stars in between like this *1*2*3*4*5*6*
here is what i have so far #include <iostream>
using namespace std;
int countSeven(int x){
if(x == 7)return 1;
int c = 0;
while(x/10 > 9)c++;
return countSeven(x/10)+1;
}
void printStarDigit(int x){
int a = 0;
while(x/10 > 0)a++;
cout << "*:"; << a << "*:";
}
when i compile it does not do what i tell it it just tells me there are 0 7's in the input number no matter how many there really are i would just like some help in the right direction thanks again
You're using recursion right, but you're not properly checking if the digit is a 7 or not. Do you know how to get just the right-most digit of a number?