0

If u know c++ help quickly on this conundrum

Help me ( c++ ) Um trying to make an a.i program but it tells me I got an error on line 18:3 ... I followed it's instructions but I couldn't tell what it meant by it expected a primary expression before ')' #include <iostream> using namespace std; class sabrina { public: void sayHi() { cout << "Hi" << endl; } }; int main() { sabrina test; test.sayHi(); int a; cout<<" how are u \n how have u been \n ? "<< endl; cin>>a; ) if (a "um okay ; um fine ; um great") {cout<< "okay thats good to hear , u know its been long ever since we talked ryt "<<endl; else { cout<<" whats the matter? \n can you tell me pls"<< endl; } } }

21st Apr 2021, 5:48 PM
Ash 3
Ash 3 - avatar
15 Réponses
+ 2
put ! in the if statement if (!strcmp (a,"um okay") &&! strcmp(a,"um fine ")) ya i know on solo learn it just print but try it on some other compiler it should run if u wanna run it on solo learn then use cin>>a; but this will scan only 1 word any word after the space will not be scan eg hello world only hello will get scanned n stored in "a"so when you display "a" cout <<a; you will only get hello
22nd Apr 2021, 3:40 AM
Seamus
Seamus - avatar
0
there is an ) on line 18 before the if statement remove it and ur if condition is wrong
21st Apr 2021, 5:51 PM
Seamus
Seamus - avatar
0
Ok let me try
21st Apr 2021, 5:53 PM
Ash 3
Ash 3 - avatar
0
By taking it out , it led to more errors in which i fixed except for one it says it expects ')' before the if statement
21st Apr 2021, 5:59 PM
Ash 3
Ash 3 - avatar
0
did you change your if condition variable a is an int even your if closing braket is wrong
21st Apr 2021, 6:02 PM
Seamus
Seamus - avatar
0
Wait , I should right it If ( int a " words " ) {}
21st Apr 2021, 6:08 PM
Ash 3
Ash 3 - avatar
0
Wouldn't calling a an int again confuse the program as it is a data variable
21st Apr 2021, 6:09 PM
Ash 3
Ash 3 - avatar
0
add a library #include <string.h> change int a; to char a [20]; and chnage cin >>a to fgets(a,20,stdin); and your if statement to if (strcmp (a,"um okay") && strcmp (a,"um fine ")) and check your if statement brackets {}
21st Apr 2021, 6:29 PM
Seamus
Seamus - avatar
0
No , it just prints out instead of giving me an opportunity to answer
21st Apr 2021, 6:47 PM
Ash 3
Ash 3 - avatar
0
And run the else statement depending on my answer
21st Apr 2021, 6:47 PM
Ash 3
Ash 3 - avatar
0
Ok , 🤣🤣🤣 I'll just copy an a.i progam from the internet and past it
22nd Apr 2021, 4:15 AM
Ash 3
Ash 3 - avatar
0
😂😂😂👍👍👍👍
22nd Apr 2021, 4:38 AM
Seamus
Seamus - avatar
0
Ash this is very simple program I can help.you fix it yourself in a simple way but u need to know the basic concepts very well.
23rd Apr 2021, 5:25 PM
Sreenesh
Sreenesh - avatar
0
👀 note that I haven't finished my c++ course yet
24th Apr 2021, 9:30 PM
Ash 3
Ash 3 - avatar
0
Yes please help me
24th Apr 2021, 9:31 PM
Ash 3
Ash 3 - avatar