0

HELP! I'm a beginner and i don't know what's wrong here! Can u help me pls?

https://code.sololearn.com/c7GZWdw4ehFB/?ref=app

28th Aug 2017, 5:54 PM
Beatrice Calegari
Beatrice Calegari - avatar
3 odpowiedzi
+ 4
#include <iostream> #include <string> using namespace std; int main() { string a =" Hi!"; string x = "How r u? "; string b = "I am fine thanks." ; string c = "Try again ):" ; string o = "good!" ; string d = a + x ; string e = a + b ; string f = "thank you (: " ; string y ; cin >> y ; if ( y == a ){ cout << a;} else if (y == x ){ cout << b;} else if (y == b){ cout<< o;} else if ( y == d){ cout<< e;} else if ( y == "good" ){ cout<< f;} else if ( y == "great" ){ cout<< f;} else if ( y == "wow" ){ cout<< f;} else { cout << " Sorry, no answer" << c;} return 0; } this is a working Code. If you want to compare two variables use == instead of = . A char variable can hold only 1 character in it. example: 'A'. you can use a char array 'char[]' or a string datatype for it.
28th Aug 2017, 6:08 PM
Max_N
Max_N - avatar
+ 1
thank you Max for helping me(:
29th Aug 2017, 5:11 AM
Beatrice Calegari
Beatrice Calegari - avatar
0
hey
3rd Sep 2017, 8:57 AM
Julien strong
Julien strong - avatar