Question: 1 . Write a C + + program that does the following: a . Create a C + + file with the name problem 4

1. Write a C++ program that does the following:
a. Create a C++ file with the name problem4.cpp.
b. Write the function unluckyusing recursion, which returns true if the first two (leftmost) digits of the positive integer parameter add up to 13, else returns false.
c. The function unluckyreturns false if the parameter has fewer than 2 digits.
d. Type in the following main function into your C++ program file:
int main()
{
int x =6789;
if (unlucky(x)) cout << x <<" is Unlucky!
";
// prints 6789 is Unlucky!
x =6889;
if (unlucky(x)) cout << x <<" is Unlucky!
";
// prints nothing.
x =6;
if (unlucky(x)) cout << x <<" is Unlucky!
";
// prints nothing.
x =49;
if (unlucky(x)) cout << x <<" is Unlucky!
";
// prints 49 is Unlucky!
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!