Question: Prob 4. Write a function called addThrees that inserts a 3 after each digit of a positive integer parameter. For example, a program that uses
Prob 4. Write a function called addThrees that inserts a 3 after each digit of a positive integer parameter. For example, a program that uses the function addThrees follows.
int main() {
cout << addThrees(3) << endl; // prints 33
cout << addThrees(1313) << endl; // prints 13331333
cout << addThrees(777) << endl; // prints 737373
return 0;
}
(just the function ); example-
(Answer: int removeLast7(int n) { if (n == 0) return 0;
if (n % 10 == 7) return n/10; return 10 * removeLast7(n/10) + n%10;)this is an example .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
