Click here to Skip to main content
15,031,687 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Python
print(' Hello, please reboot your computer and try to connect.')
answer = input('Did that fix the problem? ')
if answer != 'yes':
    print('Reboot your computer and try to connect.')
    answer = input('Did that fix the problem? ')
    if answer != 'yes':
        print('Make sure the cables between the router and modem are plugged in firmly.')
        answer = input('Did that fix the problem? ')
        if answer != 'yes':
            print('Move the router to a new location and try to connect.')
            answer = input('Did that fix the problem? ')
            if answer != 'yes':
                print('Get a New router.')


What I have tried:

I had not yet tried to code it yet
Posted
Updated 2-Dec-20 20:11pm
v2
Comments
Dave Kreskowiak 2-Dec-20 17:01pm
   
Why the hell would you want to "convert" such simple code to C++?

Just write new code that does the same thing! It's bloody obvious what's going on:

Output a message
Get user input
If (input != yes)
...repeat...

1. Learn Python
2. Learn C++
3. After figuring out what the code is supposed to do, change all the python code into its C++ equivalents.

But, to be honest you only need to understand the use of cin and cout. See iostream Programming | Microsoft Docs[^]
   
That is a pretty easy task.
C++ code would be very similar, e.g.
C++
string answer;
cout << " Hello, please reboot your computer and try to connect.\n";
cout << "Did that fix the problem? ";
cin >> answer;
if (answer != "yes")
{
  // continue here...
}
   
Comments
Patrice T 3-Dec-20 3:19am
   
5
CPallini 3-Dec-20 3:29am
   
Thank you.
This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it’ll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900