<<end1; error

I’m having issues understanding why when I put << endl; at the end of a cout in an else if statement. I get an error. Also if I don’t place the <<end1 , I get the else if and the else statement to execute at the same time. Which I’m trying to only get the else if to execute.
This is my code

#include <iostream>


int main () 
{

char ch1;
char q2;
char q3;

//// Question 1  
std::cout << "Welcome to My Program. \n";
std::cout << "Everyday we wake up in a particular mood that leads our day for the most part. \n";
std::cout << "Which mood are you waking up to? \n \n";
std::cout << "A.) Angry \n";
std::cout << "B.) Blah \n";
std::cout << "C.) Happy \n";

std::cin >> ch1;

if (ch1 == 'a' || ch1 == 'A') /// question 2
{
  std::cout << "We are off to a bad start, Everyone sucks. \n\n";
  std::cout << "What are you going to do next to change your day? \n";
  std::cout << "A.) GO GET COFFEE!! \n";
  std::cout << "B.) Just Go to Work \n";
  std::cout << "C.) Go Back To Sleep \n";

  std::cin >> q2;
}

else if (ch1 == 'b' || ch1 == 'B') /// question 3
 {
std::cout << "Nothing seems to motivate you and all you want to do is lay in bed. \n";

  std::cout << "What are you going to do next to change your day? \n";
  std::cout << "A.) GO GET COFFEE!! \n";
  std::cout << "B.) Ditch work to go to the beach! \n";
  std::cout << "C.) Go Back To Sleep \n";

  std::cin >> q3;

}
else if ( ch1 == 'c' || ch1 == 'C')
{
std::cout << "Nothing Can Ruin Your Day!! \n";
std::cout << "ENJOY!!";
}
else 
{ 
  std::cout <<"Error, Not A Choice";
}

/// Question 2
if (q2 == 'a' || q2 == 'A')
{
  std::cout << "Things Look Better, You might survive";
}
else if (q2 == 'b' || q2 == 'B')
{
  std::cout << "You're a Ticking Time Bomb!";
}
else if ( q2 == 'c' || q2 == 'C')
{
  std::cout << "Nothing can beat sleep!!" ;
}
else
 {
  std::cout <<"Error, Not A Choice" ;
}

///Question 3
if (q3 == 'a' || q3 == 'A')
{
  std::cout << "Things Look Better, You might survive";
}
else if (q3 == 'b' || q3 == 'B')
{
  std::cout << "You're day Just got Better! Enjoy!" ;
}
else if ( q3 == 'c' || q3 == 'C')
{
  std::cout << "Nothing can beat sleep!!" << endl;
}
else 
{
  std::cout <<"Error, Not A Choice";
}


}


Hi,
endl stands for end line so you should use a lowercase L instead of a 1.
There’s a case to be made that "\n", the escape character newline, is better practice but that’s a subtle touch that’s useful later rather than in the beginning.

The end1 error was made on the form. I fixed it. But I’m still having that issue where it comes up an error in the code.

Also consider what endl is… c++ is one of those languages where you don’t get as much functionality out of the box (you have to explicitly state where you are getting things from) as compared to python or javascript.

Therefore you should probably use std::endl unless you use using namespace std; in your file.

Thank you, that worked.
Now my next problem is that I have both else if statement and else statement run at the same time.
So I get this

Error, Not A ChoiceNothing can beat sleep!!

else if ( q3 == 'c' || q3 == 'C')
{
  std::cout << "Nothing can beat sleep!!" << std::endl; 
}
else 
{
  std::cout <<"Error, Not A Choice";
}

Hi,

That doesn’t sound possible within one conditional branch (but yes within the context of many branches).

I suggest writing a cout statement that highlights how things are being evaluated to debug. C++ requires really solid debugging skills so it’s part of the process to go through this.

With enough practice you’ll be able to realize the tiny errors without looking at the code (just based on the result or the error message).