Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that does a magic trick. C++ Overview: We will write a program t

ID: 3936731 • Letter: W

Question

Write a program that does a magic trick. C++

Overview: We will write a program that does a magic trick. Pick two people to create a mental link between (Person A and Person B for these instructions) Have both people secretly write down a number between 1-9. Have Person A turn away and let Person B show the audience his secret number. Have Person A secretly do the following steps: Double their secret number Add two to the result Multiply the result by five Subtract a magic number (10-Person B's number) Have Person A read out the second digit of number they computed. Instead of being the Magician, write a program that gives all the correct instructions. Your input and output can be whatever you want as long as it completes the trick.

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{ int n1,n2,a,b,c,s;
cout << "enter the secrete number of A" << endl;
cin >>n1;
cout << "enter the secrete number of B" << endl;
cin >>n2;
a=n1*2;
b=a+2;
c=b*5;
s=c-n2;
while (s >= 100)
{
s /= 10;
}
s=s%10;
cout << s;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote