1.4 Write a program that can perform the same. Your program must be different from the program in Figure 1. *Copy and paste your program AND output. #include #include using namespace std; bool mystery1(string s); bool mystery2(string s); bool mystery1(string s) { if(s.length()==0) return true; else if (s[0]=='1') else } bool mystery2(string s) { if(s.length()==0) return mystery2(s.substr(1)); return mystery1(s.substr(1)); else else if (s[0]=='1') } int main() { return false; else return mystery1(s.substr(1)); return mystery2(s.substr(1)); string s; cout << "Enter an integer:"; cin >> s; if(mystery1(s)) cout << "RESULT 1"; cout << "RESULT 2"; return 0;

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
C++
1.4 Write a program that can perform the same. Your program must be different from the
program in Figure 1.
*Copy and paste your program AND output.
#include <iostream>
#include <string>
using namespace std;
bool mystery1(string s);
bool mystery2(string s);
bool mystery1(string s)
{
if(s.length()==0)
return true;
else if (s[0]=='1')
else
bool mystery2(string s)
{
return mystery2(s.substr(1));
return mystery1(s.substr(1));
if(s.length()==0)
int main()
{
else if (s[0]=='1')
else
return false;
else
return mystery1(s.substr(1));
return mystery2(s.substr(1));
string s;
cout << "Enter an integer:";
cin >> s;
if(mystery1(s))
cout << "RESULT 1";
cout << "RESULT 2";
return 0;
Figure 1
Transcribed Image Text:C++ 1.4 Write a program that can perform the same. Your program must be different from the program in Figure 1. *Copy and paste your program AND output. #include <iostream> #include <string> using namespace std; bool mystery1(string s); bool mystery2(string s); bool mystery1(string s) { if(s.length()==0) return true; else if (s[0]=='1') else bool mystery2(string s) { return mystery2(s.substr(1)); return mystery1(s.substr(1)); if(s.length()==0) int main() { else if (s[0]=='1') else return false; else return mystery1(s.substr(1)); return mystery2(s.substr(1)); string s; cout << "Enter an integer:"; cin >> s; if(mystery1(s)) cout << "RESULT 1"; cout << "RESULT 2"; return 0; Figure 1
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning