+ 3

How to reply according to the user's input in Python and C++

Hello, guys, I need help with my application. I want to create an application that answers the user according to its input. For instance, it asks for the user's input and replies to it accordingly. If the user inputs "Hello", for example, the application replies "Hello User". I think, in the case of C++, I'd need to use the If function, but I'm not sure about how to do that.

21st Apr 2017, 10:14 PM
André Pereira
André Pereira - avatar
8 odpowiedzi
+ 4
Thanks guy!
21st Apr 2017, 10:43 PM
André Pereira
André Pereira - avatar
+ 3
Thanks. I'm a newbie at C++ programming, so...could you explain me that code?
21st Apr 2017, 10:27 PM
André Pereira
André Pereira - avatar
+ 3
And how to do this: If the user inputs "Greeting", then the application replies with "This is a Greeting for you".
21st Apr 2017, 10:45 PM
André Pereira
André Pereira - avatar
+ 3
Should I do it like this: #include <stdfx.h> #include <iostream> #include <string> int main(int argc, char *argv[]) { string x; cout << "Write something:" << endl; cin >> x; if (x = "Greeting") { cout << "This is a greeting for you"; } Return 0; }
21st Apr 2017, 10:48 PM
André Pereira
André Pereira - avatar
+ 3
Thanks, that's why the compiller marked that as a Syntax Error.
21st Apr 2017, 11:59 PM
André Pereira
André Pereira - avatar