0
HELP! I'm a beginner and i don't know what's wrong here! Can u help me pls?
3 Answers
+ 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.
+ 1
thank you Max for helping me(:
0
hey