How to reply according to the user's input in Python and C++ | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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
5 Respostas
+ 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