the program is saying expected unqualified-id on line 15. This is sooo annoying lol have been looking for solution all day. plz help if possible I will really really appreciate it. Thank you so much in advance, and regards, Michael
#include <string>
#include <iostream>
std::string answer;
usingnamespace std;
int main()
{
cout<< "are you dumb or smart?";
cin>> answer;
if (answer == "dumb")
std::cout<< "I completely agree";
else
cout<<"good to hear";
}
{
string answar;
cout<< "If given a, b, or c, what is your favorite letter?";
cin>>answar;
if (answar == "c")
cout<< "the word catastrophe starts with that letter.";
elseif (answar == "b")
cout<< "the word bactericide starts with that letter";
else
cout<< "The word apostraphe starts with that letter";
}
#include <string>
#include <iostream>
std::string answer;
usingnamespace std;
int main()
{
cout<< "are you dumb or smart?";
cin>> answer;
if (answer == "dumb")
std::cout<< "I completely agree";
else
cout<<"good to hear";
}
This is your program. The main function has finished. You can tell it has finished because of the closing brace, }. All the stuff after that is junk. It is not part of any function.
Take a good look at all the braces and work out where they are meant to go.
#include <string>
#include <iostream>
std::string answer;
usingnamespace std;
int main()
{
cout<< "are you dumb or smart?";
cin>> answer;
if (answer == "dumb")
std::cout<< "I completely agree";
else
cout<<"good to hear";
string answar;
cout<< "If given a, b, or c, what is your favorite letter?";
cin>>answar;
if (answar == "c")
cout<< "the word catastrophe starts with that letter.";
elseif (answar == "b")
cout<< "the word bactericide starts with that letter";
else
cout<< "The word apostraphe starts with that letter";
return 0;
}
xhtmix, hi, you just helped me fix my other program! :) thanks. I learned from internet mostly, few from book, too boring lol. Anyways, I tried to do it with only one pair of braces, and it had a bazillion errors. Thank you guys for the help. xhtmix, I really appreciate it you are the best!!!. Thanks again.
oh wait btw, It worked, and I added a bit, but now when It ask for name it just shows lldb as reply, but no problem sign. Thank you soo soo much xhtmix. the following code
#include <string>
#include <iostream>
usingnamespace std;
string answer;
string answar;
string name;
int main()
{
cout<< "why hello, what is your name?";
cin>> name;
cout<< "what a nice name:" << name;
cout<<"\n";
cout<< "lemme give you some questions...";
cout<<"\n";
cout<< "are you dumb or smart?";
cin>> answer;
if (answer == "dumb")
cout<< "I completely agree";
elseif (answer == "smart")
cout<<"good to hear";
cout<<"\n";
cout<<"\n";
cout<< "If given a, b, or c, what is your favorite letter?";
cin>>answar;
if (answar == "c")
cout<< "the word catastrophe starts with that letter.";
elseif (answar == "b")
cout<< "the word bactericide starts with that letter";
elseif (answar == "a")
cout<< "The word apostraphe starts with that letter";
return 0;
}